Skip to content

Commit af3bb46

Browse files
committed
Fix --flush command to work with contexts (#175)
1 parent f04766a commit af3bb46

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ system, you must also run the `--upgrade` command in each repository:
4646
### Fixed
4747

4848
- Prevent `cd` commands printing out excess details when `CDPATH` is set (#156)
49+
- Fix `--flush` command to work with contexts (#175)
4950

5051
### Changed
5152

transcrypt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -702,18 +702,11 @@ display_configuration() {
702702

703703
# remove transcrypt-related settings from the repository's git config
704704
clean_gitconfig() {
705-
git config --remove-section transcrypt 2>/dev/null || true
706-
git config --remove-section filter.crypt 2>/dev/null || true
707-
git config --remove-section diff.crypt 2>/dev/null || true
708-
git config --remove-section merge.crypt 2>/dev/null || true
709-
git config --unset merge.renormalize
710-
711-
# remove the merge section if it's now empty
712-
local merge_values
713-
merge_values=$(git config --get-regex --local 'merge\..*') || true
714-
if [[ ! $merge_values ]]; then
715-
git config --remove-section merge 2>/dev/null || true
716-
fi
705+
git config --remove-section transcrypt"${CONTEXT_CONFIG_GROUP}" 2>/dev/null || true
706+
707+
git config --remove-section filter.crypt"${CONTEXT_CRYPT_SUFFIX}" 2>/dev/null || true
708+
git config --remove-section diff.crypt"${CONTEXT_CRYPT_SUFFIX}" 2>/dev/null || true
709+
git config --remove-section merge.crypt"${CONTEXT_CRYPT_SUFFIX}" 2>/dev/null || true
717710
}
718711

719712
# Remove from the local Git DB any objects containing the cached plaintext of
@@ -776,6 +769,15 @@ flush_credentials() {
776769
# re-encrypt any files that had been previously decrypted
777770
force_checkout
778771

772+
# Unset the ls-crypt alias for the current context
773+
# We must do this after the force checkout, which relies on ls-crypt
774+
git config --unset alias.ls-crypt"${CONTEXT_CRYPT_SUFFIX}" 2>/dev/null || true
775+
776+
# Also remove ls-crypt-default alias when removing default context
777+
if [[ "$CONTEXT" = 'default' ]]; then
778+
git config --unset alias.ls-crypt-default 2>/dev/null || true
779+
fi
780+
779781
printf 'The local transcrypt credentials have been successfully flushed.\n'
780782
else
781783
die 1 'flushing of credentials has been aborted'
@@ -864,6 +866,20 @@ uninstall_transcrypt() {
864866
git config --remove-section alias 2>/dev/null || true
865867
fi
866868

869+
# unset merge.renormalize if all transcrypt configs are now removed
870+
local transcrypt_values
871+
transcrypt_values=$(git config --get-regex --local 'transcrypt\..*') || true
872+
if [[ ! $transcrypt_values ]]; then
873+
git config --unset merge.renormalize
874+
fi
875+
876+
# remove the merge section if it's now empty
877+
local merge_values
878+
merge_values=$(git config --get-regex --local 'merge\..*') || true
879+
if [[ ! $merge_values ]]; then
880+
git config --remove-section merge 2>/dev/null || true
881+
fi
882+
867883
# remove any defined crypt patterns in gitattributes
868884
case $OSTYPE in
869885
darwin*)

0 commit comments

Comments
 (0)