* git-subtree Patches to Apply
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git
Here are all of the patches for git-subtree that have been posted to
the mailing list that I could apply and test in a reasonable amount of
time. These are all rebased from trunk as of tonight.
Many apologies for being *so* behind. Work has been a bear but I'm
hoping things will ease up in the new year and I can be more regularly
active. But still, don't expect same-day service. :)
These are also available on branch "toupstream" via
git clone gitolite@sources.obbligato.org:git.git
and
http://sources.obbligato.org
http://sources.obbligato.org/?p=git.git;a=summary
Junio, can you apply these? Thanks!
-David
^ permalink raw reply
* [PATCH 1/8] Use %B for Split Subject/Body
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Use %B to format the commit message and body to avoid an extra newline
if a commit only has a subject line.
Author: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 5 +++
contrib/subtree/t/t7900-subtree.sh | 73 ++++++++++++++++++++++--------------
2 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 920c664..f2b6d4a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -296,7 +296,12 @@ copy_commit()
# We're going to set some environment vars here, so
# do it in a subshell to get rid of them safely later
debug copy_commit "{$1}" "{$2}" "{$3}"
+ # Use %B rather than %s%n%n%b to handle the special case of a
+ # commit that only has a subject line. We don't want to
+ # introduce a newline after the subject, causing generation of
+ # a new hash.
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
+# git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
(
read GIT_AUTHOR_NAME
read GIT_AUTHOR_EMAIL
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index bc2eeb0..93eeb09 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -76,6 +76,10 @@ test_expect_success 'add sub1' '
git branch -m master subproj
'
+# Save this hash for testing later.
+
+subdir_hash=`git rev-parse HEAD`
+
# 3
test_expect_success 'add sub2' '
create sub2 &&
@@ -155,7 +159,6 @@ test_expect_success 'add main-sub5' '
create subdir/main-sub5 &&
git commit -m "main-sub5"
'
-
# 15
test_expect_success 'add main6' '
create main6 &&
@@ -235,7 +238,19 @@ test_expect_success 'check split with --branch' '
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
'
-# 25
+#25
+test_expect_success 'check hash of split' '
+ spl1=$(git subtree split --prefix subdir) &&
+ undo &&
+ git subtree split --prefix subdir --branch splitbr1test &&
+ check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
+ git checkout splitbr1test &&
+ new_hash=$(git rev-parse HEAD~2) &&
+ git checkout mainline &&
+ check_equal ''"$new_hash"'' "$subdir_hash"
+'
+
+# 26
test_expect_success 'check split with --branch for an existing branch' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
@@ -244,13 +259,13 @@ test_expect_success 'check split with --branch for an existing branch' '
check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
'
-# 26
+# 27
test_expect_success 'check split with --branch for an incompatible branch' '
test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
'
-# 27
+# 28
test_expect_success 'check split+rejoin' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
@@ -258,7 +273,7 @@ test_expect_success 'check split+rejoin' '
check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
'
-# 28
+# 29
test_expect_success 'add main-sub8' '
create subdir/main-sub8 &&
git commit -m "main-sub8"
@@ -267,14 +282,14 @@ test_expect_success 'add main-sub8' '
# To the subproject!
cd ./subproj
-# 29
+# 30
test_expect_success 'merge split into subproj' '
git fetch .. spl1 &&
git branch spl1 FETCH_HEAD &&
git merge FETCH_HEAD
'
-# 30
+# 31
test_expect_success 'add sub9' '
create sub9 &&
git commit -m "sub9"
@@ -283,19 +298,19 @@ test_expect_success 'add sub9' '
# Back to mainline
cd ..
-# 31
+# 32
test_expect_success 'split for sub8' '
split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
git branch split2 "$split2"
'
-# 32
+# 33
test_expect_success 'add main-sub10' '
create subdir/main-sub10 &&
git commit -m "main-sub10"
'
-# 33
+# 34
test_expect_success 'split for sub10' '
spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
git branch spl3 "$spl3"
@@ -304,7 +319,7 @@ test_expect_success 'split for sub10' '
# To the subproject!
cd ./subproj
-# 34
+# 35
test_expect_success 'merge split into subproj' '
git fetch .. spl3 &&
git branch spl3 FETCH_HEAD &&
@@ -318,13 +333,13 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
-# 35
+# 36
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
subfiles=''"$(git ls-files | fixnl)"'' &&
check_equal "$subfiles" "$chkms $chks"
'
-# 36
+# 37
test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
check_equal "$allchanges" "$chkms $chks"
@@ -333,20 +348,20 @@ test_expect_success 'make sure the subproj history *only* contains commits that
# Back to mainline
cd ..
-# 37
+# 38
test_expect_success 'pull from subproj' '
git fetch ./subproj subproj-merge-spl3 &&
git branch subproj-merge-spl3 FETCH_HEAD &&
git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
'
-# 38
+# 39
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
mainfiles=''"$(git ls-files | fixnl)"'' &&
check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
-# 39
+# 40
test_expect_success 'make sure each filename changed exactly once in the entire history' '
# main-sub?? and /subdir/main-sub?? both change, because those are the
# changes that were split into their own history. And subdir/sub?? never
@@ -355,12 +370,12 @@ test_expect_success 'make sure each filename changed exactly once in the entire
check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
'
-# 40
+# 41
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
'
-# 41
+# 42
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
# They are meaningless to subproj since one side of the merge refers to the mainline
check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
@@ -370,14 +385,14 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
mkdir test2
cd test2
-# 42
+# 43
test_expect_success 'init main' '
test_create_repo main
'
cd main
-# 43
+# 44
test_expect_success 'add main1' '
create main1 &&
git commit -m "main1"
@@ -385,14 +400,14 @@ test_expect_success 'add main1' '
cd ..
-# 44
+# 45
test_expect_success 'init sub' '
test_create_repo sub
'
cd sub
-# 45
+# 46
test_expect_success 'add sub2' '
create sub2 &&
git commit -m "sub2"
@@ -402,7 +417,7 @@ cd ../main
# check if split can find proper base without --onto
-# 46
+# 47
test_expect_success 'add sub as subdir in main' '
git fetch ../sub master &&
git branch sub2 FETCH_HEAD &&
@@ -411,7 +426,7 @@ test_expect_success 'add sub as subdir in main' '
cd ../sub
-# 47
+# 48
test_expect_success 'add sub3' '
create sub3 &&
git commit -m "sub3"
@@ -419,20 +434,20 @@ test_expect_success 'add sub3' '
cd ../main
-# 48
+# 49
test_expect_success 'merge from sub' '
git fetch ../sub master &&
git branch sub3 FETCH_HEAD &&
git subtree merge --prefix subdir sub3
'
-# 49
+# 50
test_expect_success 'add main-sub4' '
create subdir/main-sub4 &&
git commit -m "main-sub4"
'
-# 50
+# 51
test_expect_success 'split for main-sub4 without --onto' '
git subtree split --prefix subdir --branch mainsub4
'
@@ -442,12 +457,12 @@ test_expect_success 'split for main-sub4 without --onto' '
# have been sub3, but it was not, because its cache was not set to
# itself)
-# 51
+# 52
test_expect_success 'check that the commit parent is sub3' '
check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
'
-# 52
+# 53
test_expect_success 'add main-sub5' '
mkdir subdir2 &&
create subdir2/main-sub5 &&
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3/8] Better Error Handling for add
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: "David A. Greene" <greened@obbligato.org>
Check refspecs for validity before passing them on to other commands.
This lets us generate more helpful error messages.
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7ceb413..b8a807a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -509,8 +509,20 @@ cmd_add()
ensure_clean
if [ $# -eq 1 ]; then
+ ref=$(git check-ref-format --normalize "refs/heads/$1") ||
+ die "'$1' is not a valid refspec. Are you missing a branch?"
+
+ rev=$(git rev-parse --verify $1) ||
+ die "'$1' is not a valid refspec. Are you missing a branch?"
+
"cmd_add_commit" "$@"
elif [ $# -eq 2 ]; then
+ ref=$(git check-ref-format --normalize "refs/heads/$2") ||
+ die "'$2' is not a valid refspec."
+
+ rev=$(git rev-parse --verify $2) ||
+ die "'$2' is not a valid refspec."
+
"cmd_add_repository" "$@"
else
say "error: parameters were '$@'"
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/8] Add --unannotate
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: James Nylen, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: James Nylen <jnylen@gmail.com>
Teach git-subtree about --unannotate. This option strips a prefix
from a commit message when doing a subtree split.
Author: James Nylen <jnylen@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 11 +++++-
contrib/subtree/git-subtree.txt | 15 ++++++++
contrib/subtree/t/t7900-subtree.sh | 73 ++++++++++++++++++++----------------
3 files changed, 65 insertions(+), 34 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index f2b6d4a..7ceb413 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -21,6 +21,7 @@ P,prefix= the name of the subdir to split out
m,message= use the given message as the commit message for the merge commit
options for 'split'
annotate= add a prefix to commit message of new commits
+unannotate= remove a prefix from new commit messages (supports bash globbing)
b,branch= create a new branch from the split subtree
ignore-joins ignore prior --rejoin commits
onto= try connecting new tree to an existing one
@@ -43,6 +44,7 @@ onto=
rejoin=
ignore_joins=
annotate=
+unannotate=
squash=
message=
@@ -80,6 +82,8 @@ while [ $# -gt 0 ]; do
-d) debug=1 ;;
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
+ --unannotate) unannotate="$1"; shift ;;
+ --no-unannotate) unannotate= ;;
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-m) message="$1"; shift ;;
@@ -315,8 +319,11 @@ copy_commit()
GIT_COMMITTER_NAME \
GIT_COMMITTER_EMAIL \
GIT_COMMITTER_DATE
- (echo -n "$annotate"; cat ) |
- git commit-tree "$2" $3 # reads the rest of stdin
+ (
+ read FIRST_LINE
+ echo "$annotate${FIRST_LINE#$unannotate}"
+ cat # reads the rest of stdin
+ ) | git commit-tree "$2" $3
) || die "Can't copy commit $1"
}
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 0c44fda..ae420aa 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -198,6 +198,21 @@ OPTIONS FOR split
git subtree tries to make it work anyway, particularly
if you use --rejoin, but it may not always be effective.
+--unannotate=<annotation>::
+ This option is only valid for the split command.
+
+ When generating synthetic history, try to remove the prefix
+ <annotation> from each commit message (using bash's "strip
+ shortest match from beginning" command, which supports
+ globbing). This makes sense if you format library commits
+ like "library: Change something or other" when you're working
+ in your project's repository, but you want to remove this
+ prefix when pushing back to the library's upstream repository.
+ (In this case --unannotate='*: ' would work well.)
+
+ Like --annotate, you need to use the same <annotation>
+ whenever you split, or you may run into problems.
+
-b <branch>::
--branch=<branch>::
This option is only valid for the split command.
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 93eeb09..9816da5 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -157,7 +157,7 @@ test_expect_success 'merge fetched subproj' '
# 14
test_expect_success 'add main-sub5' '
create subdir/main-sub5 &&
- git commit -m "main-sub5"
+ git commit -m "subproj: main-sub5"
'
# 15
test_expect_success 'add main6' '
@@ -168,7 +168,7 @@ test_expect_success 'add main6' '
# 16
test_expect_success 'add main-sub7' '
create subdir/main-sub7 &&
- git commit -m "main-sub7"
+ git commit -m "subproj: main-sub7"
'
# 17
@@ -238,7 +238,7 @@ test_expect_success 'check split with --branch' '
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
'
-#25
+# 25
test_expect_success 'check hash of split' '
spl1=$(git subtree split --prefix subdir) &&
undo &&
@@ -251,6 +251,15 @@ test_expect_success 'check hash of split' '
'
# 26
+test_expect_success 'check --unannotate' '
+ spl1=$(git subtree split --unannotate='"subproj:"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
+ undo &&
+ git subtree split --unannotate='"subproj:"' --prefix subdir --onto FETCH_HEAD --branch splitunann &&
+ check_equal ''"$(git rev-parse splitunann)"'' "$spl1" &&
+ check_equal ''"$(git log splitunann | grep subproj)"'' ""
+'
+
+# 27
test_expect_success 'check split with --branch for an existing branch' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
@@ -259,13 +268,13 @@ test_expect_success 'check split with --branch for an existing branch' '
check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
'
-# 27
+# 28
test_expect_success 'check split with --branch for an incompatible branch' '
test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
'
-# 28
+# 29
test_expect_success 'check split+rejoin' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
@@ -273,7 +282,7 @@ test_expect_success 'check split+rejoin' '
check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
'
-# 29
+# 30
test_expect_success 'add main-sub8' '
create subdir/main-sub8 &&
git commit -m "main-sub8"
@@ -282,14 +291,14 @@ test_expect_success 'add main-sub8' '
# To the subproject!
cd ./subproj
-# 30
+# 31
test_expect_success 'merge split into subproj' '
git fetch .. spl1 &&
git branch spl1 FETCH_HEAD &&
git merge FETCH_HEAD
'
-# 31
+# 32
test_expect_success 'add sub9' '
create sub9 &&
git commit -m "sub9"
@@ -298,19 +307,19 @@ test_expect_success 'add sub9' '
# Back to mainline
cd ..
-# 32
+# 33
test_expect_success 'split for sub8' '
split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
git branch split2 "$split2"
'
-# 33
+# 34
test_expect_success 'add main-sub10' '
create subdir/main-sub10 &&
git commit -m "main-sub10"
'
-# 34
+# 35
test_expect_success 'split for sub10' '
spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
git branch spl3 "$spl3"
@@ -319,7 +328,7 @@ test_expect_success 'split for sub10' '
# To the subproject!
cd ./subproj
-# 35
+# 36
test_expect_success 'merge split into subproj' '
git fetch .. spl3 &&
git branch spl3 FETCH_HEAD &&
@@ -333,13 +342,13 @@ chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
-# 36
+# 37
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
subfiles=''"$(git ls-files | fixnl)"'' &&
check_equal "$subfiles" "$chkms $chks"
'
-# 37
+# 38
test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
check_equal "$allchanges" "$chkms $chks"
@@ -348,20 +357,20 @@ test_expect_success 'make sure the subproj history *only* contains commits that
# Back to mainline
cd ..
-# 38
+# 39
test_expect_success 'pull from subproj' '
git fetch ./subproj subproj-merge-spl3 &&
git branch subproj-merge-spl3 FETCH_HEAD &&
git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
'
-# 39
+# 40
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
mainfiles=''"$(git ls-files | fixnl)"'' &&
check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
-# 40
+# 41
test_expect_success 'make sure each filename changed exactly once in the entire history' '
# main-sub?? and /subdir/main-sub?? both change, because those are the
# changes that were split into their own history. And subdir/sub?? never
@@ -370,12 +379,12 @@ test_expect_success 'make sure each filename changed exactly once in the entire
check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
'
-# 41
+# 42
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
'
-# 42
+# 43
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
# They are meaningless to subproj since one side of the merge refers to the mainline
check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
@@ -385,14 +394,14 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
mkdir test2
cd test2
-# 43
+# 44
test_expect_success 'init main' '
test_create_repo main
'
cd main
-# 44
+# 45
test_expect_success 'add main1' '
create main1 &&
git commit -m "main1"
@@ -400,14 +409,14 @@ test_expect_success 'add main1' '
cd ..
-# 45
+# 46
test_expect_success 'init sub' '
test_create_repo sub
'
cd sub
-# 46
+# 47
test_expect_success 'add sub2' '
create sub2 &&
git commit -m "sub2"
@@ -417,7 +426,7 @@ cd ../main
# check if split can find proper base without --onto
-# 47
+# 48
test_expect_success 'add sub as subdir in main' '
git fetch ../sub master &&
git branch sub2 FETCH_HEAD &&
@@ -426,7 +435,7 @@ test_expect_success 'add sub as subdir in main' '
cd ../sub
-# 48
+# 49
test_expect_success 'add sub3' '
create sub3 &&
git commit -m "sub3"
@@ -434,20 +443,20 @@ test_expect_success 'add sub3' '
cd ../main
-# 49
+# 50
test_expect_success 'merge from sub' '
git fetch ../sub master &&
git branch sub3 FETCH_HEAD &&
git subtree merge --prefix subdir sub3
'
-# 50
+# 51
test_expect_success 'add main-sub4' '
create subdir/main-sub4 &&
git commit -m "main-sub4"
'
-# 51
+# 52
test_expect_success 'split for main-sub4 without --onto' '
git subtree split --prefix subdir --branch mainsub4
'
@@ -457,19 +466,19 @@ test_expect_success 'split for main-sub4 without --onto' '
# have been sub3, but it was not, because its cache was not set to
# itself)
-# 52
+# 53
test_expect_success 'check that the commit parent is sub3' '
check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
'
-# 53
+# 54
test_expect_success 'add main-sub5' '
mkdir subdir2 &&
create subdir2/main-sub5 &&
git commit -m "main-sub5"
'
-# 53
+# 55
test_expect_success 'split for main-sub5 without --onto' '
# also test that we still can split out an entirely new subtree
# if the parent of the first commit in the tree is not empty,
@@ -502,7 +511,7 @@ joincommits()
echo "$commit $all"
}
-# 54
+# 56
test_expect_success 'verify one file change per commit' '
x= &&
list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
--
1.7.10.4
^ permalink raw reply related
* [PATCH 4/8] Fix Synopsis
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: "David A. Greene" <greened@obbligato.org>
Fix the documentation of add to show that a repository can be
specified along with a commit.
Change "commit" to "refspec" in the synopsis for add.
Suggested by Yann Dirson <dirson@bertin.fr>.
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 3 ++-
contrib/subtree/git-subtree.txt | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index b8a807a..ad62dfb 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -8,7 +8,8 @@ if [ $# -eq 0 ]; then
set -- -h
fi
OPTS_SPEC="\
-git subtree add --prefix=<prefix> <commit>
+git subtree add --prefix=<prefix> <refspec>
+git subtree add --prefix=<prefix> <repository> <refspec>
git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
git subtree push --prefix=<prefix> <repository> <refspec...>
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index ae420aa..89c2d6e 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -9,7 +9,8 @@ git-subtree - Merge subtrees together and split repository into subtrees
SYNOPSIS
--------
[verse]
-'git subtree' add -P <prefix> <commit>
+'git subtree' add -P <prefix> <refspec>
+'git subtree' add -P <prefix> <repository> <refspec>
'git subtree' pull -P <prefix> <repository> <refspec...>
'git subtree' push -P <prefix> <repository> <refspec...>
'git subtree' merge -P <prefix> <commit>
--
1.7.10.4
^ permalink raw reply related
* [PATCH 5/8] Honor DESTDIR
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: Adam Tkac, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: Adam Tkac <atkac@redhat.com>
Teach git-subtree's Makefile to honor DESTDIR.
Author: Adam Tkac <atkac@redhat.com>
Signed-off-by: Adam Tkac <atkac@redhat.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/Makefile b/contrib/subtree/Makefile
index 05cdd5c..36ae3e4 100644
--- a/contrib/subtree/Makefile
+++ b/contrib/subtree/Makefile
@@ -30,12 +30,12 @@ $(GIT_SUBTREE): $(GIT_SUBTREE_SH)
doc: $(GIT_SUBTREE_DOC)
install: $(GIT_SUBTREE)
- $(INSTALL) -m 755 $(GIT_SUBTREE) $(libexecdir)
+ $(INSTALL) -m 755 $(GIT_SUBTREE) $(DESTDIR)$(libexecdir)
install-doc: install-man
install-man: $(GIT_SUBTREE_DOC)
- $(INSTALL) -m 644 $^ $(man1dir)
+ $(INSTALL) -m 644 $^ $(DESTDIR)$(man1dir)
$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
xmlto -m $(MANPAGE_NORMAL_XSL) man $^
--
1.7.10.4
^ permalink raw reply related
* [PATCH 6/8] Make the Manual Directory if Needed
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: Jesper L. Nielsen, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: "Jesper L. Nielsen" <lyager@gmail.com>
Before install git-subtree documentation, make sure the manpage
directory exists.
Author: Jesper L. Nielsen <lyager@gmail.com>
Signed-off-by: Jesper L. Nielsen <lyager@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/contrib/subtree/Makefile b/contrib/subtree/Makefile
index 36ae3e4..52d6fb9 100644
--- a/contrib/subtree/Makefile
+++ b/contrib/subtree/Makefile
@@ -35,6 +35,7 @@ install: $(GIT_SUBTREE)
install-doc: install-man
install-man: $(GIT_SUBTREE_DOC)
+ mkdir -p $(man1dir)
$(INSTALL) -m 644 $^ $(DESTDIR)$(man1dir)
$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 8/8] Fix Documentation Typo
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: Michael Schubert, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: Michael Schubert <mschub@elegosoft.com>
"split" is documented below "push" so fix the reference to it in
push's documentation.
Author: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 89c2d6e..078d4ac 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -94,7 +94,7 @@ pull::
repository.
push::
- Does a 'split' (see above) using the <prefix> supplied
+ Does a 'split' (see below) using the <prefix> supplied
and then does a 'git push' to push the result to the
repository and refspec. This can be used to push your
subtree to different branches of the remote repository.
--
1.7.10.4
^ permalink raw reply related
* [PATCH 7/8] Ignore git-subtree
From: David A. Greene @ 2013-01-01 3:57 UTC (permalink / raw)
To: git; +Cc: Michael Schubert, David A. Greene
In-Reply-To: <1357012655-24974-1-git-send-email-greened@obbligato.org>
From: Michael Schubert <mschub@elegosoft.com>
Add the git-subtree command executable to .gitignore.
Author: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/contrib/subtree/.gitignore b/contrib/subtree/.gitignore
index 7e77c9d..91360a3 100644
--- a/contrib/subtree/.gitignore
+++ b/contrib/subtree/.gitignore
@@ -1,4 +1,5 @@
*~
+git-subtree
git-subtree.xml
git-subtree.1
mainline
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] subtree.sh: Use raw subject and body modifier "%B" instead of "%s%n%n%b"
From: greened @ 2013-01-01 3:59 UTC (permalink / raw)
To: Techlive Zheng; +Cc: git, gitster, apenwarr
In-Reply-To: <87mwwt4yp4.fsf@waller.obbligato.org>
greened@obbligato.org writes:
> I've applied this patch to my working copy but I'm not finding that I
> can recreate the original problem when the patch is disabled.
^ not
-David
^ permalink raw reply
* Re: git subtree error (just how do you expect me to merge 0 trees?)
From: greened @ 2013-01-01 4:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Drew Crawford, git@vger.kernel.org
In-Reply-To: <7v7gnxd24h.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
>> With one positional option, git-subtree add simply assumes
>> it's a refspec. Is there an easy way to check whether a string is a
>> proper refspec? Even better would be a way to check if a string is a
>> path to a git repository.
>
> Do you literally mean "a path to a repository" in the above, or do
> you mean "a remote that is like what is accepted by 'git fetch'"?
It's the latter as git-subtree calls git-fetch to do the work of
getting revisions.
> On the other hand, if you mean the command takes a remote and an
> optional list of refspecs just like "git fetch" does, then I am not
> sure it is a good design in the first place to allow "refspecs
> only", if only to keep the interface similar to "git fetch" (you
> cannot omit remote and give refspecs, as you cannot interpret
> refspecs without knowing in the context of which remote they are to
> be interpreted).
If just a refspec is given, git-subtree does a rev-parse in the current
directory and that seems to work fine. It's what I as a user would
expect to happen.
> I would imagine you could disambiguate and default to "origin" or
> something when you guessed that remote was omitted if you really
> wanted to, with a syntacitical heuristics, such as "a refspec will
> never have two colons in it", "a URL tends to begin with a short
> alphabet word, a colon and double-slash", etc.
Hmm...I haven't added code to verify the repository/remote argument if
given. I suppose a rev-parse --verify would suffice?
-David
^ permalink raw reply
* Re: [PATCH 1/8] Use %B for Split Subject/Body
From: greened @ 2013-01-01 4:06 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng
In-Reply-To: <1357012655-24974-2-git-send-email-greened@obbligato.org>
"David A. Greene" <greened@obbligato.org> writes:
> From: Techlive Zheng <techlivezheng@gmail.com>
>
> Use %B to format the commit message and body to avoid an extra newline
> if a commit only has a subject line.
Wow. So that was a spectacular fail. Sorry about th duplicate patch
e-mails. I have no idea how that happened.
-David
^ permalink raw reply
* Re: [RFC] pack-objects: compression level for non-blobs
From: Duy Nguyen @ 2013-01-01 4:15 UTC (permalink / raw)
To: Jeff King; +Cc: Shawn Pearce, David Michael Barr, Git Mailing List
In-Reply-To: <CAJo=hJtjtpiPVd6Koy9q5je7s7A4EyDa-CptJNCnHLSLgd9W7g@mail.gmail.com>
On Tue, Jan 1, 2013 at 1:06 AM, Shawn Pearce <spearce@spearce.org> wrote:
>> 3. Dropping the "commits" file and just using the pack-*.idx as the
>> index. The problem is that it is sparse in the commit space. So
>> just naively storing 40 bytes per entry is going to waste a lot of
>> space. If we had a separate index as in (1) above, that could be
>> dropped to (say) 4 bytes of offset per object. But still, right now
>> the commits file for linux-2.6 is about 7.2M (20 bytes times ~376K
>> commits). There are almost 3 million total objects, so even storing
>> 4 bytes per object is going to be worse.
>
> Fix pack-objects to behave the way JGit does, cluster commits first in
> the pack stream. Now you have a dense space of commits. If I remember
> right this has a tiny positive improvement for most rev-list
> operations with very little downside.
I was going to suggest a similar thing. The current state of C Git's
pack writing is not bad. We mix commits and tags together, but tags
are few usually. Once we get the upper and lower bound, in terms of
object position in the pack, of the commit+tag region, we could reduce
the waste significantly. That is if you sort the cache by the object
order in the pack.
--
Duy
^ permalink raw reply
* Re: git subtree error (just how do you expect me to merge 0 trees?)
From: Junio C Hamano @ 2013-01-01 5:54 UTC (permalink / raw)
To: greened; +Cc: Drew Crawford, git@vger.kernel.org
In-Reply-To: <87d2xpwnty.fsf@waller.obbligato.org>
greened@obbligato.org writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>>> With one positional option, git-subtree add simply assumes
>>> it's a refspec. Is there an easy way to check whether a string is a
>>> proper refspec? Even better would be a way to check if a string is a
>>> path to a git repository.
>>
>> Do you literally mean "a path to a repository" in the above, or do
>> you mean "a remote that is like what is accepted by 'git fetch'"?
>
> It's the latter as git-subtree calls git-fetch to do the work of
> getting revisions.
If that is the case, t should behave similar to 'git fetch' for
consistency. If you want to name "current repository", you can
simply give "." as the repository parameter; this has long been
supported by 'git fetch' (as 'git pull . $branch' has been the way
to say 'git merge' for a long time).
^ permalink raw reply
* Re: [PATCH 1/8] Use %B for Split Subject/Body
From: Junio C Hamano @ 2013-01-01 5:56 UTC (permalink / raw)
To: David A. Greene; +Cc: git, Techlive Zheng
In-Reply-To: <1357012655-24974-2-git-send-email-greened@obbligato.org>
"David A. Greene" <greened@obbligato.org> writes:
> From: Techlive Zheng <techlivezheng@gmail.com>
>
> Use %B to format the commit message and body to avoid an extra newline
> if a commit only has a subject line.
Is this an unconditional improvement, or is it generally an
improvement but for some users it may be a regression? I am
guessing it is the former but am just making sure.
> Author: Techlive Zheng <techlivezheng@gmail.com>
>
> Signed-off-by: David A. Greene <greened@obbligato.org>
Please don't do "Author: " which does not add anything new. That is
what "From: " is for. Instead it needs to be a sign-off.
Also, is that a real name, I have to wonder?
Thanks.
^ permalink raw reply
* Re: [PATCH 1/8] Use %B for Split Subject/Body
From: Junio C Hamano @ 2013-01-01 5:58 UTC (permalink / raw)
To: greened; +Cc: git, Techlive Zheng
In-Reply-To: <87wqvxv96q.fsf@waller.obbligato.org>
greened@obbligato.org writes:
> "David A. Greene" <greened@obbligato.org> writes:
>
>> From: Techlive Zheng <techlivezheng@gmail.com>
>>
>> Use %B to format the commit message and body to avoid an extra newline
>> if a commit only has a subject line.
>
> Wow. So that was a spectacular fail. Sorry about th duplicate patch
> e-mails. I have no idea how that happened.
>
> -David
Also, please be careful about the subject line. I doubt that these
8 patches will stand out as relating to "contrib/subtree", when mixed
in 200 line output of "git shortlog --no-merges".
Thanks.
^ permalink raw reply
* [PATCH 1/3] config.txt: a few lines about branch.<name>.description
From: Nguyễn Thái Ngọc Duy @ 2013-01-01 9:30 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/config.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index bf8f911..ee64846 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -735,6 +735,12 @@ branch.<name>.rebase::
it unless you understand the implications (see linkgit:git-rebase[1]
for details).
+branch.<name>.description::
+ Branch description, can be edited with
+ `git branch --edit-description`. Branch description is
+ automatically added in the format-patch cover letter or
+ request-pull summary.
+
browser.<tool>.cmd::
Specify the command to invoke the specified browser. The
specified command is evaluated in shell with the URLs passed
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* [PATCH 2/3] format-patch: pick up branch description when no ref is specified
From: Nguyễn Thái Ngọc Duy @ 2013-01-01 9:30 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
In-Reply-To: <1357032655-21103-1-git-send-email-pclouds@gmail.com>
find_branch_name() fails to detect "format-patch --cover-letter -3"
where no command line arguments are given and HEAD is automatically
added. Detect branch name in this case so we can pick up the branch's
description in cover letter.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/log.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/builtin/log.c b/builtin/log.c
index e7b7db1..115f118 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1027,8 +1027,22 @@ static char *find_branch_name(struct rev_info *rev)
else
return NULL;
}
- if (positive < 0)
+ if (positive < 0) {
+ /*
+ * No actual ref from command line, but "HEAD" from
+ * rev->def was added in setup_revisions()
+ * e.g. format-patch --cover-letter -12
+ */
+ if (!rev->cmdline.nr &&
+ rev->pending.nr == 1 &&
+ !strcmp(rev->pending.objects[0].name, "HEAD")) {
+ const char *ref;
+ ref = resolve_ref_unsafe("HEAD", branch_sha1, 1, NULL);
+ if (ref && !prefixcmp(ref, "refs/heads/"))
+ return xstrdup(ref + strlen("refs/heads/"));
+ }
return NULL;
+ }
strbuf_addf(&buf, "refs/heads/%s", rev->cmdline.rev[positive].name);
branch = resolve_ref_unsafe(buf.buf, branch_sha1, 1, NULL);
if (!branch ||
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* [PATCH 3/3] branch: delete branch description if it's empty
From: Nguyễn Thái Ngọc Duy @ 2013-01-01 9:30 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
In-Reply-To: <1357032655-21103-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
I don't see the value of having an empty branch description. But I
may be missing something.
builtin/branch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 1ec9c02..873f624 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -725,7 +725,7 @@ static int edit_branch_description(const char *branch_name)
stripspace(&buf, 1);
strbuf_addf(&name, "branch.%s.description", branch_name);
- status = git_config_set(name.buf, buf.buf);
+ status = git_config_set(name.buf, buf.len ? buf.buf : NULL);
strbuf_release(&name);
strbuf_release(&buf);
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* Re: [PATCH] Remove the suggestion to use parsecvs, which is currently broken.
From: Chris Packham @ 2013-01-01 10:05 UTC (permalink / raw)
To: Eric S. Raymond; +Cc: git
In-Reply-To: <20121228162025.8565E4413A@snark.thyrsus.com>
Minor typo
On 12/29/2012 05:20 AM, Eric S. Raymond wrote:
> The parsecvs code has been neglected for a long time, and the only
> public version does not even build correctly. I have been handed
> control of the project and intend to fix this, but until I do it
> cannot be recommended.
>
> Also, the project URL given for Subversion needed to be updated
> to follow their site move.
> ---
> Documentation/git-cvsimport.txt | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
> index 98d9881..9d5353e 100644
> --- a/Documentation/git-cvsimport.txt
> +++ b/Documentation/git-cvsimport.txt
> @@ -213,11 +213,9 @@ Problems related to tags:
> * Multiple tags on the same revision are not imported.
>
> If you suspect that any of these issues may apply to the repository you
> -want to import consider using these alternative tools which proved to be
> -more stable in practice:
> +want to imort, consider using cvs2git:
s/imort/import/
>
> -* cvs2git (part of cvs2svn), `http://cvs2svn.tigris.org`
> -* parsecvs, `http://cgit.freedesktop.org/~keithp/parsecvs`
> +* cvs2git (part of cvs2svn), `http://subversion.apache.org/`
>
> GIT
> ---
>
^ permalink raw reply
* Re: [RFC] pack-objects: compression level for non-blobs
From: Duy Nguyen @ 2013-01-01 12:10 UTC (permalink / raw)
To: Jeff King
Cc: Shawn Pearce, David Michael Barr, Git Mailing List,
Junio C Hamano
In-Reply-To: <CACsJy8CygfaM+Ee6rURFB-cP2khO8URGDJMG2f3mqg0ebYz+8Q@mail.gmail.com>
On Tue, Jan 1, 2013 at 11:15 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>> Fix pack-objects to behave the way JGit does, cluster commits first in
>> the pack stream. Now you have a dense space of commits. If I remember
>> right this has a tiny positive improvement for most rev-list
>> operations with very little downside.
>
> I was going to suggest a similar thing. The current state of C Git's
> pack writing is not bad. We mix commits and tags together, but tags
And I was wrong. At least since 1b4bb16 (pack-objects: optimize
"recency order" - 2011-06-30) commits are spread out and can be mixed
with trees too. Grouping them back defeats what Junio did in that
commit, I think.
--
Duy
^ permalink raw reply
* Re: git filter-branch doesn't dereference annotated tags
From: Johannes Sixt @ 2013-01-01 12:30 UTC (permalink / raw)
To: Grégory Pakosz; +Cc: git
In-Reply-To: <CAC_01E174m_6tDwPKZ5P0BUxnLNWUf9p+VkECFosPTzip0sYsA@mail.gmail.com>
Am 31.12.2012 17:24, schrieb Grégory Pakosz:
> Please disregard the previous email that contains an incorrect fix
> suggestion. I wish my first contribution was flawless.
>
> Here is what's happening.
> git-filter-branch let git-update-ref -d verify that the value for $ref
> matches $sha1.
> However, when $ref points to an annotated tag that is being deleted,
> that verification fails because $sha1 is the commit underneath.
>
> I think there are two possible fixes:
> 1) either make git-filter-branch dereference annotated tags and do
> the verification itself then use the two arguments version of git
> update-ref
> 2) in the case of an annotated tag, pass another <old value> to git update-ref
>
> Please find below a patch that implements solution 1). Please note the
> patch doesn't contain a unit test for this situation as I wasn't sure
> how to provide one. Yet I tested it on the repository I'm working on.
>
> Gregory
We write material like this below the three-dash line of the patch.
>
> From 9d21960088a61bfbac1ffdb4b13e3038f88ab4d6 Mon Sep 17 00:00:00 2001
> From: Gregory Pakosz <gpakosz@visionobjects.com>
> Date: Mon, 31 Dec 2012 15:30:36 +0100
Then you can remove these three lines because they are inferred from the
email message. And you should not attach the patch, only place it
inline, but make sure that it is not line-wrapped and space-mangled on
the mail route.
> Subject: [PATCH] git-filter-branch: support annotated tags deletion
>
> git-filter-branch let git-update-ref -d verify that the value for $ref matches
> $sha1. However, when $ref is an annotated tag being deleted that verfication
> fails because $sha1 corresponds to a commit object.
>
> Instead of asking git-update-ref to verify values actually match, dereference
> $ref ourselves and test against $sha1 first. Then invoke git-update-ref with two
> arguments.
It would have been very helpful if you could summarize the conditions
under which the unexpected behavior happens in the commit message. A
test case would also be great; it should be a matter of inserting
another case in t/t7003.
Without that information, I can't decide whether it is a good thing that
a tag (annotated or not) is deleted, because we have --tag-name-filter
to treat tags (even though you can't delete tags with this feature).
> Signed-off-by: Gregory Pakosz <gpakosz@visionobjects.com>
> ---
> git-filter-branch.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 5314249..bbee6d0 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -383,7 +383,7 @@ do
> case "$rewritten" in
> '')
> echo "Ref '$ref' was deleted"
> - git update-ref -m "filter-branch: delete" -d "$ref" $sha1 ||
> + test $(git rev-parse --verify "$ref^{commit}") = $sha1 && git
> update-ref -m "filter-branch: delete" -d "$ref" ||
> die "Could not delete $ref"
As written, it counts as error "Could not delete $ref" if the test...
command fails. Is this intended?
-- Hannes
^ permalink raw reply
* Re: git filter-branch doesn't dereference annotated tags
From: Grégory Pakosz @ 2013-01-01 13:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vsj6mdqeo.fsf@alter.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 4328 bytes --]
> Thanks. A few comments.
>
> At the design level. Where does this $sha1 come from in the first
> place?
>
actually, sha1=$(git rev-parse "$ref"^0)
(please remember that I'm discovering git internals while figuring out
how to make git filter-branch work in my use case)
in my use case, $ref is "refs/tags/4.0" which is an annotated tag
$ git rev-parse "refs/tags/4.0"
e941b1999906c17b59320f776d58b71fc2fcdb72
$ git cat-file -t e941b1999906c17b59320f776d58b71fc2fcdb72
tag
$ git rev-parse e941b1999906c17b59320f776d58b71fc2fcdb72^0
dcd7cdc18240dd9a54b30d757dd2347f52040490
$ git cat-file -t dcd7cdc18240dd9a54b30d757dd2347f52040490
commit
so $sha1 is dcd7cdc18240dd9a54b30d757dd2347f52040490
and then git-filter-branch calls git update-ref -m "filter-branch:
delete" -d "refs/tags/4.0" dcd7cdc18240dd9a54b30d757dd2347f52040490
which makes git update-index complains
e941b1999906c17b59320f776d58b71fc2fcdb72 !=
dcd7cdc18240dd9a54b30d757dd2347f52040490
so hmm, adding test $(git rev-parse --verify "$ref^{commit}") = $sha1
as I did in my patch is always true since sha1=$(git rev-parse
"$ref"^0)
> If a ref that named the annotated tag was deleted, shouldn't
> we arrange things so this part of the code receives the $sha1 of the
> tag that corresponds to the $ref
>
I'm not sure what you mean by "a ref that named the annotated tag was deleted"
What's happening in my situation is that the commit the tag points to
gets rewritten to nothing as the result of my filtering:
"refs/tags/4.0" points to e941b1999906c17b59320f776d58b71fc2fcdb72
(tag) which points to dcd7cdc18240dd9a54b30d757dd2347f52040490
(commit) which gets rewritten to nothing so the tag must be deleted.
> so that "update-ref -d" can check
> that nobody tampered with the repository while the script was
> working?
>
I'm not quite sure what could possibly go well if somebody tampers
with the repository while it's being filtered with git filter-branch
anyways???
If we want to address "did somebody tamper with the repository while
the script was working?", then test $(git rev-parse --verify
"$ref^{commit}") = $sha1 verifies somebody didn't tamper with $ref
since we got $sha1 from it.
But that doesn't ensure tampering didn't take place in between
test $(git rev-parse --verify "$ref^{commit}") = $sha1
and
git update-ref -m "filter-branch: delete" -d "$ref".
How defensive should git filter-branch really be?
> At the implementation level. When the ref being deleted pointed at
> a tree or a blob, the original would have correctly removed it, but
> will the updated one?
>
Yes.
Now that you made me think about it even more, the title of that
thread isn't "git filter-branch doesn't dereference annotated tags".
It in fact does as per sha1=$(git rev-parse "$ref"^0).
Maybe the suggested fix should be: in case the tag points to a commit
that has been rewritten to nothing, get $sha1 again without
dereferencing recursively with sha1=$(git rev-parse "$ref") then use
the 3 arguments versions of git update-ref as before.
Thanks for reading
Gregory
>From 59f86c9c07715734d59009c15816220f996b75be Mon Sep 17 00:00:00 2001
From: Gregory Pakosz <gpakosz@visionobjects.com>
Date: Mon, 31 Dec 2012 15:30:36 +0100
Subject: [PATCH] git-filter-branch: support annotated tags deletion
git-filter-branch let git-update-ref -d verify that the value for $ref matches
$sha1. $sha1 is obtained form dereferencing $ref recursively. In case $sha1 gets
rewritten to nothing as per result of the filtering, the tag should be deleted.
However, in case of an annotated tag, git-update-ref -d fails because $ref
doesn't directly point to $sha1.
To make git-filter-branch properly delete an annotated tag, obtain $sha1 again
withouth dereferencing the tag before asking git-update-ref to verify $ref and
$sha1 match.
Signed-off-by: Gregory Pakosz <gpakosz@visionobjects.com>
---
git-filter-branch.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 5314249..7ae9912 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -383,6 +383,7 @@ do
case "$rewritten" in
'')
echo "Ref '$ref' was deleted"
+ test $(git cat-file -t "$ref") = 'tag' && sha1=$(git rev-parse "$ref")
git update-ref -m "filter-branch: delete" -d "$ref" $sha1 ||
die "Could not delete $ref"
;;
--
1.8.0.1
[-- Attachment #2: 0001-git-filter-branch-support-annotated-tags-deletion.patch --]
[-- Type: application/octet-stream, Size: 1285 bytes --]
From 59f86c9c07715734d59009c15816220f996b75be Mon Sep 17 00:00:00 2001
From: Gregory Pakosz <gpakosz@visionobjects.com>
Date: Mon, 31 Dec 2012 15:30:36 +0100
Subject: [PATCH] git-filter-branch: support annotated tags deletion
git-filter-branch let git-update-ref -d verify that the value for $ref matches
$sha1. $sha1 is obtained form dereferencing $ref recursively. In case $sha1 gets
rewritten to nothing as per result of the filtering, the tag should be deleted.
However, in case of an annotated tag, git-update-ref -d fails because $ref
doesn't directly point to $sha1.
To make git-filter-branch properly delete an annotated tag, obtain $sha1 again
withouth dereferencing the tag before asking git-update-ref to verify $ref and
$sha1 match.
Signed-off-by: Gregory Pakosz <gpakosz@visionobjects.com>
---
git-filter-branch.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 5314249..7ae9912 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -383,6 +383,7 @@ do
case "$rewritten" in
'')
echo "Ref '$ref' was deleted"
+ test $(git cat-file -t "$ref") = 'tag' && sha1=$(git rev-parse "$ref")
git update-ref -m "filter-branch: delete" -d "$ref" $sha1 ||
die "Could not delete $ref"
;;
--
1.8.0.1
^ permalink raw reply related
* [PATCH] Correct example restore from bundle
From: Kirill Brilliantov @ 2013-01-01 13:54 UTC (permalink / raw)
To: git
Without use branche option repository restory without files:
$ git clone pr.bundle q/
Cloning into 'q'...
Receiving objects: 100% (619/619), 13.52 MiB | 18.74 MiB/s, done.
Resolving deltas: 100% (413/413), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ ls -aF q/
./ ../ .git/
Signed-off-by: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>
---
Documentation/git-bundle.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt
index 16a6b0a..6c31715 100644
--- a/Documentation/git-bundle.txt
+++ b/Documentation/git-bundle.txt
@@ -118,7 +118,7 @@ were a remote repository instead of creating an empty repository and then
pulling or fetching objects from the bundle:
----------------
-machineB$ git clone /home/me/tmp/file.bundle R2
+machineB$ git clone /home/me/tmp/file.bundle R2 -b master
----------------
This will define a remote called "origin" in the resulting repository that
--
1.7.10.4
^ permalink raw reply related
* [PATCH] Correct example restore from bundle
From: Kirill Brilliantov @ 2013-01-01 15:26 UTC (permalink / raw)
To: git
Without use branche option repository restory without files:
$ git clone pr.bundle q/
Cloning into 'q'...
Receiving objects: 100% (619/619), 13.52 MiB | 18.74 MiB/s, done.
Resolving deltas: 100% (413/413), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ ls -aF q/
./ ../ .git/
Signed-off-by: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>
---
Documentation/git-bundle.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt
index 16a6b0a..6c31715 100644
--- a/Documentation/git-bundle.txt
+++ b/Documentation/git-bundle.txt
@@ -118,7 +118,7 @@ were a remote repository instead of creating an empty repository and then
pulling or fetching objects from the bundle:
----------------
-machineB$ git clone /home/me/tmp/file.bundle R2
+machineB$ git clone /home/me/tmp/file.bundle R2 -b master
----------------
This will define a remote called "origin" in the resulting repository that
--
1.7.10.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox