From e5c1b2b1e45a224e6fab81c04c7a387da5ace47b Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Fri, 20 Sep 2019 19:42:52 +0300 Subject: [PATCH 1/2] git-backport-diff: eat git numbers when comparing Hashes and some specific numbers never matches when comparing them. Match them and substitute by corresponding place holders. Signed-off-by: Vladimir Sementsov-Ogievskiy --- git-backport-diff | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-backport-diff b/git-backport-diff index 2ae090f..8fc0aab 100755 --- a/git-backport-diff +++ b/git-backport-diff @@ -210,6 +210,11 @@ then upstream_valid='y' fi +eat_git_numbers() { + sed -e 's/^index .*/index /' -e 's/^@@ .* @@/@@ @@/' \ + -e 's/^commit .*/commit /' -e 's/^Date:.*00/Date: /' +} + numdiff=0 label= subjlist= @@ -281,7 +286,7 @@ compare_git() label="--label=\"Patch #$cnt: $subj\" --label=\" \"" fi subjlist[$cnt]=$subj - exe[$cnt]="${label} <(git show $uphash^!) <(git show $downhash^!) 2>/dev/null" + exe[$cnt]="${label} <(git show $uphash^! | eat_git_numbers) <(git show $downhash^! | eat_git_numbers) 2>/dev/null" shortexe[$cnt]="<(git show ${uphash:0:7}^\!) <(git show ${downhash:0:7}^\!)" fi else From ef70f07cd73fc80f961cfd8424e243b02b29bcff Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Fri, 20 Sep 2019 19:57:43 +0300 Subject: [PATCH 2/2] git-backport-diff: use files to diff vimdiff don't support --label option and the simplest way to hint user, which commit is being compared is use appropriate file-names - vim will show them (if correspondingly configured, ofcourse). Signed-off-by: Vladimir Sementsov-Ogievskiy --- git-backport-diff | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-backport-diff b/git-backport-diff index 8fc0aab..e2604d3 100755 --- a/git-backport-diff +++ b/git-backport-diff @@ -286,7 +286,12 @@ compare_git() label="--label=\"Patch #$cnt: $subj\" --label=\" \"" fi subjlist[$cnt]=$subj - exe[$cnt]="${label} <(git show $uphash^! | eat_git_numbers) <(git show $downhash^! | eat_git_numbers) 2>/dev/null" + tmp_dir=$(mktemp -d) + uphash_file="$tmp_dir/[up-$cnt]-$(git log --format=%f -n 1 $uphash).patch" + downhash_file="$tmp_dir/[down-$cnt]-$(git log --format=%f -n 1 $downhash).patch" + git show $uphash | eat_git_numbers > "$uphash_file" + git show $downhash | eat_git_numbers > "$downhash_file" + exe[$cnt]="${label} ${uphash_file} ${downhash_file} 2>/dev/null" shortexe[$cnt]="<(git show ${uphash:0:7}^\!) <(git show ${downhash:0:7}^\!)" fi else