Download raw body.
regress: change how trim_obj_id works
trim_obj_ids is a bit weird IMHO in that you have to specify how many characters to drop *from the end* instead of how many to keep from the beginning. This comes in the way of enabling some parts of the regress for sha256 since object IDs are longer, and a `trim_obj_id 38` will not yield 2 characters, but 26! Instead, what about using the numeric argument to mean the number of characters to keep from the beginning? Then `trim_obj_id 2` will always return the first two characters, regardless of the length of the hash. The diff boils down to @@ -132,13 +132,7 @@ trim_obj_id() local trimcount=$1 local id=$2 - local pat="" - while [ "$trimcount" -gt 0 ]; do - pat="[0-9a-f]$pat" - trimcount=$((trimcount - 1)) - done - - echo ${id%$pat} + echo "$id" | sed -E "s/^([0-9a-f]{$trimcount}).*/\1/" } plus a mechanical fix for all the places where it's used. Regress of course passes. ok? commit 553426743804abd0ac5b68de14678c3b83b5d52d (sha256) from: Omar Polo <op@omarpolo.com> date: Sat Jul 13 13:17:11 2024 UTC swap trim_obj_id behaviour diff a96c0eca406fbbdec4a21b0fc2589bdbc9c0d04a 553426743804abd0ac5b68de14678c3b83b5d52d commit - a96c0eca406fbbdec4a21b0fc2589bdbc9c0d04a commit + 553426743804abd0ac5b68de14678c3b83b5d52d blob - d60fc3d989f80b6803c66daddd2280f9ac6bee96 blob + d029636f37e1e06a4fba931a86782da565457b03 --- regress/cmdline/blame.sh +++ regress/cmdline/blame.sh @@ -61,9 +61,9 @@ test_blame_basic() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - local short_commit1=`trim_obj_id 32 $commit1` - local short_commit2=`trim_obj_id 32 $commit2` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit1=`trim_obj_id 8 $commit1` + local short_commit2=`trim_obj_id 8 $commit2` + local short_commit3=`trim_obj_id 8 $commit3` d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected @@ -110,8 +110,8 @@ test_blame_tag() { (cd $testroot/wt && got blame -c $tag alpha > $testroot/stdout) - local short_commit1=`trim_obj_id 32 $commit1` - local short_commit2=`trim_obj_id 32 $commit2` + local short_commit1=`trim_obj_id 8 $commit1` + local short_commit2=`trim_obj_id 8 $commit2` d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected @@ -147,7 +147,7 @@ test_blame_file_single_line() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected @@ -182,7 +182,7 @@ test_blame_file_single_line_no_newline() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected @@ -208,7 +208,7 @@ test_blame_all_lines_replaced() { seq 8 > $testroot/wt/alpha (cd $testroot/wt && got commit -m "change 1" > /dev/null) local commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` local author_time=`git_show_author_time $testroot/repo` (cd $testroot/wt && got blame alpha > $testroot/stdout) @@ -245,7 +245,7 @@ test_blame_lines_shifted_up() { seq 8 > $testroot/wt/alpha (cd $testroot/wt && got commit -m "change 1" > /dev/null) local commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` local author_time=`git_show_author_time $testroot/repo` ed -s $testroot/wt/alpha <<-\EOF @@ -254,7 +254,7 @@ test_blame_lines_shifted_up() { EOF (cd $testroot/wt && got commit -m "change 2" > /dev/null) local commit2=`git_show_head $testroot/repo` - local short_commit2=`trim_obj_id 32 $commit2` + local short_commit2=`trim_obj_id 8 $commit2` seq 2 > $testroot/wt/alpha echo foo >> $testroot/wt/alpha @@ -263,7 +263,7 @@ test_blame_lines_shifted_up() { seq 6 8 >> $testroot/wt/alpha (cd $testroot/wt && got commit -m "change 3" > /dev/null) local commit3=`git_show_head $testroot/repo` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit3=`trim_obj_id 8 $commit3` local author_time=`git_show_author_time $testroot/repo` (cd $testroot/wt && got blame alpha > $testroot/stdout) @@ -304,7 +304,7 @@ test_blame_lines_shifted_down() { seq 8 > $testroot/wt/alpha (cd $testroot/wt && got commit -m "change 1" > /dev/null) local commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` local author_time=`git_show_author_time $testroot/repo` ed -s $testroot/wt/alpha <<-\EOF @@ -313,7 +313,7 @@ test_blame_lines_shifted_down() { EOF (cd $testroot/wt && got commit -m "change 2" > /dev/null) local commit2=`git_show_head $testroot/repo` - local short_commit2=`trim_obj_id 32 $commit2` + local short_commit2=`trim_obj_id 8 $commit2` seq 2 > $testroot/wt/alpha echo foo >> $testroot/wt/alpha @@ -322,7 +322,7 @@ test_blame_lines_shifted_down() { seq 3 8 >> $testroot/wt/alpha (cd $testroot/wt && got commit -m "change 3" > /dev/null) local commit3=`git_show_head $testroot/repo` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit3=`trim_obj_id 8 $commit3` local author_time=`git_show_author_time $testroot/repo` (cd $testroot/wt && got blame alpha > $testroot/stdout) @@ -398,7 +398,7 @@ dvi: # do nothing to build dvi EOF (cd $testroot/wt && got commit -m "change 1" > /dev/null) local commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` local author_time1=`git_show_author_time $testroot/repo` local d1=`date -u -r $author_time1 +"%F"` @@ -425,7 +425,7 @@ EOF # all changes in this commit will be subsumed by later commits (cd $testroot/wt && got commit -m "change 2" > /dev/null) local commit2=`git_show_head $testroot/repo` - local short_commit2=`trim_obj_id 32 $commit2` + local short_commit2=`trim_obj_id 8 $commit2` local author_time2=`git_show_author_time $testroot/repo` local d2=`date -u -r $author_time2 +"%F"` @@ -449,7 +449,7 @@ dvi: # do nothing to build dvi EOF (cd $testroot/wt && got commit -m "change 3" > /dev/null) local commit3=`git_show_head $testroot/repo` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit3=`trim_obj_id 8 $commit3` local author_time3=`git_show_author_time $testroot/repo` local d3=`date -u -r $author_time3 +"%F"` @@ -473,7 +473,7 @@ dvi: # do nothing to build dvi EOF (cd $testroot/wt && got commit -m "change 4" > /dev/null) local commit4=`git_show_head $testroot/repo` - local short_commit4=`trim_obj_id 32 $commit4` + local short_commit4=`trim_obj_id 8 $commit4` local author_time4=`git_show_author_time $testroot/repo` local d4=`date -u -r $author_time4 +"%F"` @@ -720,9 +720,9 @@ test_blame_added_on_branch() { (cd $testroot/wt && got blame new > $testroot/stdout) - local short_commit1=`trim_obj_id 32 $commit1` - local short_commit2=`trim_obj_id 32 $commit2` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit1=`trim_obj_id 8 $commit1` + local short_commit2=`trim_obj_id 8 $commit2` + local short_commit3=`trim_obj_id 8 $commit3` d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected @@ -772,7 +772,7 @@ test_blame_submodule() { test_blame_symlink() { local testroot=`test_init blame_symlink` local commit_id0=`git_show_head $testroot/repo` - local short_commit0=`trim_obj_id 32 $commit_id0` + local short_commit0=`trim_obj_id 8 $commit_id0` (cd $testroot/repo && ln -s alpha alpha.link) (cd $testroot/repo && ln -s epsilon epsilon.link) @@ -783,7 +783,7 @@ test_blame_symlink() { git_commit $testroot/repo -m "add symlinks" local commit_id1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit_id1` + local short_commit1=`trim_obj_id 8 $commit_id1` local author_time=`git_show_author_time $testroot/repo` # got blame dereferences symlink to a regular file @@ -907,7 +907,7 @@ D EOF (cd $testroot/wt && got commit -m "change 1" > /dev/null) local commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 32 $commit1` + local short_commit1=`trim_obj_id 8 $commit1` local author_time1=`git_show_author_time $testroot/repo` cat > $testroot/wt/alpha <<EOF @@ -920,7 +920,7 @@ Q EOF (cd $testroot/wt && got commit -m "change 2" > /dev/null) local commit2=`git_show_head $testroot/repo` - local short_commit2=`trim_obj_id 32 $commit2` + local short_commit2=`trim_obj_id 8 $commit2` local author_time2=`git_show_author_time $testroot/repo` cat > $testroot/wt/alpha <<EOF @@ -934,7 +934,7 @@ Q EOF (cd $testroot/wt && got commit -m "change 3" > /dev/null) local commit3=`git_show_head $testroot/repo` - local short_commit3=`trim_obj_id 32 $commit3` + local short_commit3=`trim_obj_id 8 $commit3` local author_time3=`git_show_author_time $testroot/repo` cat > $testroot/wt/alpha <<EOF @@ -947,7 +947,7 @@ Q EOF (cd $testroot/wt && got commit -m "change 4" > /dev/null) local commit4=`git_show_head $testroot/repo` - local short_commit4=`trim_obj_id 32 $commit4` + local short_commit4=`trim_obj_id 8 $commit4` local author_time4=`git_show_author_time $testroot/repo` cat > $testroot/wt/alpha <<EOF @@ -961,7 +961,7 @@ Q EOF (cd $testroot/wt && got commit -m "change 5" > /dev/null) local commit5=`git_show_head $testroot/repo` - local short_commit5=`trim_obj_id 32 $commit5` + local short_commit5=`trim_obj_id 8 $commit5` local author_time5=`git_show_author_time $testroot/repo` (cd $testroot/wt && got blame alpha > $testroot/stdout) @@ -997,7 +997,7 @@ test_blame_commit_keywords() { local wt="$testroot/wt" local id=$(git_show_head "$repo") - set -- "$(trim_obj_id 32 $id)" + set -- "$(trim_obj_id 8 $id)" # :base requires work tree echo "got: '-c :base' requires work tree" > "$testroot/stderr.expected" @@ -1038,7 +1038,7 @@ test_blame_commit_keywords() { fi id=$(git_show_head "$repo") - set -- "$@" "$(trim_obj_id 32 $id)" + set -- "$@" "$(trim_obj_id 8 $id)" done local author_time=$(git_show_author_time "$repo") blob - fa88b8e9da3292f78931b60f217cfd5ede722f86 blob + a43ed7a5edf97dd118bdc839444f242a3b12dbe4 --- regress/cmdline/common.sh +++ regress/cmdline/common.sh @@ -132,13 +132,7 @@ trim_obj_id() local trimcount=$1 local id=$2 - local pat="" - while [ "$trimcount" -gt 0 ]; do - pat="[0-9a-f]$pat" - trimcount=$((trimcount - 1)) - done - - echo ${id%$pat} + echo "$id" | sed -E "s/^([0-9a-f]{$trimcount}).*/\1/" } pop_idx() @@ -201,7 +195,7 @@ get_loose_object_path() { local repo="$1" local id="$2" - local id0=`trim_obj_id 38 $id` + local id0=`trim_obj_id 2 $id` local idrest=`echo ${id#[0-9a-f][0-9a-f]}` echo "$repo/.git/objects/$id0/$idrest" } blob - 758167f8b5e07885c9944d76d57660a8d0a7afc1 blob + c7454905559296ba3c95edb66a8cf17f0700d11a --- regress/cmdline/histedit.sh +++ regress/cmdline/histedit.sh @@ -55,10 +55,10 @@ test_histedit_no_op() { local new_commit2=`git_show_head $testroot/repo` local new_author_time2=`git_show_author_time $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -267,10 +267,10 @@ test_histedit_swap() { local new_commit2=`git_show_parent_commit $testroot/repo` local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G epsilon/zeta" > $testroot/stdout.expected echo -n "$short_old_commit2 -> $short_new_commit2: " \ @@ -388,9 +388,9 @@ test_histedit_drop() { local new_commit2=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "$short_old_commit1 -> drop commit: committing changes" \ > $testroot/stdout.expected @@ -511,11 +511,11 @@ EOF local new_commit1=`git_show_parent_commit $testroot/repo` local new_commit2=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_old_commit3=`trim_obj_id 28 $old_commit3` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_old_commit3=`trim_obj_id 12 $old_commit3` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -617,8 +617,8 @@ test_histedit_edit() { (cd $testroot/wt && got histedit -F $testroot/histedit-script \ > $testroot/stdout) - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -675,8 +675,8 @@ EOF local new_commit1=`git_show_parent_commit $testroot/repo` local new_commit2=`git_show_head $testroot/repo` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "$short_old_commit1 -> $short_new_commit1: committing changes" \ > $testroot/stdout.expected @@ -926,8 +926,8 @@ test_histedit_abort() { (cd $testroot/wt && got histedit -F $testroot/histedit-script \ > $testroot/stdout) - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -1058,8 +1058,8 @@ test_histedit_path_prefix_drop() { (cd $testroot/wt && got histedit -F $testroot/histedit-script \ > $testroot/stdout) - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` echo "$short_old_commit1 -> drop commit: changing zeta" \ > $testroot/stdout.expected @@ -1161,7 +1161,7 @@ test_histedit_path_prefix_edit() { (cd $testroot/wt && got histedit -F $testroot/histedit-script \ > $testroot/stdout) - local short_old_commit1=`trim_obj_id 28 $old_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` echo "G zeta" > $testroot/stdout.expected echo "Stopping histedit for amending commit $old_commit1" \ @@ -1212,7 +1212,7 @@ EOF got histedit -c > $testroot/stdout) local new_commit1=`git_show_head $testroot/repo` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo -n "$short_old_commit1 -> $short_new_commit1: " \ > $testroot/stdout.expected @@ -1359,9 +1359,9 @@ EOF local new_commit=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit=`trim_obj_id 28 $new_commit` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit=`trim_obj_id 12 $new_commit` echo "G epsilon/zeta" >> $testroot/stdout.expected echo -n "$short_old_commit2 -> fold commit: committing to zeta " \ @@ -1395,12 +1395,12 @@ test_histedit_split_commit() { git -C $testroot/repo add epsilon/new git_commit $testroot/repo -m "committing changes 1" local old_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` echo "modified zeta on master" > $testroot/repo/epsilon/zeta git_commit $testroot/repo -m "committing changes 2" local old_commit2=`git_show_head $testroot/repo` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit2=`trim_obj_id 12 $old_commit2` got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null ret=$? @@ -1471,7 +1471,7 @@ test_histedit_split_commit() { return 1 fi local new_commit2=`git_show_head $testroot/repo` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "$short_old_commit1 -> no-op change: committing changes 1" \ > $testroot/stdout.expected @@ -1587,10 +1587,10 @@ EOF local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_old_commit3=`trim_obj_id 28 $old_commit3` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_old_commit3=`trim_obj_id 12 $old_commit3` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "A epsilon/psi" >> $testroot/stdout.expected echo "$short_old_commit1 -> fold commit: committing changes" \ @@ -1690,9 +1690,9 @@ EOF local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "G alpha" >> $testroot/stdout.expected echo "$short_old_commit1 -> fold commit: modified alpha" \ @@ -1779,9 +1779,9 @@ EOF local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "D alpha" > $testroot/stdout.expected echo "$short_old_commit1 -> fold commit: removing alpha" \ @@ -1859,11 +1859,11 @@ EOF local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_old_commit3=`trim_obj_id 28 $old_commit3` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_old_commit3=`trim_obj_id 12 $old_commit3` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -1978,12 +1978,12 @@ EOF local new_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local very_short_old_commit1=`trim_obj_id 29 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` - local short_old_commit3=`trim_obj_id 28 $old_commit3` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local very_short_old_commit1=`trim_obj_id 11 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` + local short_old_commit3=`trim_obj_id 12 $old_commit3` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -2083,8 +2083,8 @@ test_histedit_edit_only() { (cd $testroot/wt && got histedit -e > $testroot/stdout) - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_old_commit2=`trim_obj_id 12 $old_commit2` echo "G alpha" > $testroot/stdout.expected echo "D beta" >> $testroot/stdout.expected @@ -2115,7 +2115,7 @@ EOF local new_commit1=$(cd $testroot/wt && got info | \ grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ') - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo -n "$short_old_commit1 -> $short_new_commit1: " \ > $testroot/stdout.expected @@ -2146,7 +2146,7 @@ EOF VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout) local new_commit2=`git_show_head $testroot/repo` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo -n "$short_old_commit2 -> $short_new_commit2: " \ > $testroot/stdout.expected @@ -2437,8 +2437,8 @@ EOF local new_commit1=`git_show_head $testroot/repo` local new_author_time1=`git_show_author_time $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "G alpha" > $testroot/stdout.expected echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \ @@ -2530,9 +2530,9 @@ test_histedit_drop_only() { (cd $testroot/wt && got histedit -d > $testroot/stdout) local new_commit1=`git_show_head $testroot/repo` - local short_commit1=`trim_obj_id 28 $drop_commit1` - local short_commit2=`trim_obj_id 28 $drop_commit2` - local short_commit3=`trim_obj_id 28 $drop_commit3` + local short_commit1=`trim_obj_id 12 $drop_commit1` + local short_commit2=`trim_obj_id 12 $drop_commit2` + local short_commit3=`trim_obj_id 12 $drop_commit3` echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected @@ -2618,17 +2618,17 @@ test_histedit_conflict_revert() { echo "first change of alpha" > $testroot/repo/alpha git_commit $testroot/repo -m "committing changes" local old_commit1=`git_show_head $testroot/repo` - local short_old_commit1=`trim_obj_id 28 $old_commit1` + local short_old_commit1=`trim_obj_id 12 $old_commit1` echo "second change of alpha" > $testroot/repo/alpha git_commit $testroot/repo -m "committing changes" local old_commit2=`git_show_head $testroot/repo` - local short_old_commit2=`trim_obj_id 28 $old_commit2` + local short_old_commit2=`trim_obj_id 12 $old_commit2` echo "third change of alpha" > $testroot/repo/alpha git_commit $testroot/repo -m "committing changes" local old_commit3=`git_show_head $testroot/repo` - local short_old_commit3=`trim_obj_id 28 $old_commit3` + local short_old_commit3=`trim_obj_id 12 $old_commit3` got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null ret=$? @@ -2672,7 +2672,7 @@ EOF local new_commit1=$(cd $testroot/wt && got info | \ grep 'work tree base commit:' | cut -d ' ' -f5) - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "$short_old_commit1 -> $short_new_commit1: committing changes" \ > $testroot/stdout.expected blob - d8eb96bab4f0e3966cb1fb48167fcf1be88c38f7 blob + b1c3c8ec3866e7ac66371da08256f2fa1212a13c --- regress/cmdline/log.sh +++ regress/cmdline/log.sh @@ -1275,10 +1275,10 @@ test_log_toposort() { local merge_commit=`git_show_head $testroot/repo` local merge_time=`git_show_author_time $testroot/repo` - local short_commit0=`trim_obj_id 33 $commit0` - local short_commit1=`trim_obj_id 33 $commit1` - local short_commit2=`trim_obj_id 33 $commit2` - local short_commit3=`trim_obj_id 33 $commit3` + local short_commit0=`trim_obj_id 7 $commit0` + local short_commit1=`trim_obj_id 7 $commit1` + local short_commit2=`trim_obj_id 7 $commit2` + local short_commit3=`trim_obj_id 7 $commit3` d_0=`date -u -r $author_time0 +"%F"` d_1=`date -u -r $author_time1 +"%F"` blob - fdc97d042d96cc880bf32dab15045285d6a80e27 blob + c824aaf0100a26fa4d112f62f5136272c5c82bbc --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -67,10 +67,10 @@ test_rebase_basic() { local new_commit2=`git_show_head $testroot/repo` local new_author_time2=`git_show_author_time $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G gamma/delta" >> $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -293,7 +293,7 @@ test_rebase_continue() { echo "modified alpha on branch" > $testroot/repo/alpha git_commit $testroot/repo -m "committing to alpha on newbranch" local orig_commit1=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` git -C $testroot/repo checkout -q master echo "modified alpha on master" > $testroot/repo/alpha @@ -395,7 +395,7 @@ EOF git -C $testroot/repo checkout -q newbranch local new_commit1=`git_show_head $testroot/repo` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo -n "$short_orig_commit1 -> $short_new_commit1" \ > $testroot/stdout.expected @@ -432,7 +432,7 @@ test_rebase_abort() { echo "modified beta on branch" > $testroot/repo/beta git_commit $testroot/repo -m "committing to beta on newbranch" local orig_commit1=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` echo "modified alpha on branch" > $testroot/repo/alpha echo "new file on branch" > $testroot/repo/epsilon/new @@ -440,7 +440,7 @@ test_rebase_abort() { git_commit $testroot/repo \ -m "changing alpha and adding new on newbranch" local orig_commit2=`git_show_head $testroot/repo` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` git -C $testroot/repo checkout -q master echo "modified alpha on master" > $testroot/repo/alpha @@ -462,7 +462,7 @@ test_rebase_abort() { new_commit1=$(cd $testroot/wt && got info beta | \ grep '^based on commit:' | cut -d' ' -f4) - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "G beta" > $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -628,7 +628,7 @@ test_rebase_no_op_change() { echo "modified alpha on branch" > $testroot/repo/alpha git_commit $testroot/repo -m "committing to alpha on newbranch" local orig_commit1=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` git -C $testroot/repo checkout -q master echo "modified alpha on master" > $testroot/repo/alpha @@ -743,7 +743,7 @@ test_rebase_in_progress() { echo "modified alpha on branch" > $testroot/repo/alpha git_commit $testroot/repo -m "committing to alpha on newbranch" local orig_commit1=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` git -C $testroot/repo checkout -q master echo "modified alpha on master" > $testroot/repo/alpha @@ -904,8 +904,8 @@ test_rebase_path_prefix() { local new_commit1=`git_show_parent_commit $testroot/repo` local new_commit2=`git_show_head $testroot/repo` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G gamma/delta" > $testroot/stdout.expected echo -n "$short_orig_commit2 -> $short_new_commit2" \ @@ -1364,10 +1364,10 @@ test_rebase_trims_empty_dir() { local new_commit1=`git_show_parent_commit $testroot/repo` local new_commit2=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G gamma/delta" >> $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -1463,8 +1463,8 @@ test_rebase_delete_missing_file() { local orig_commit1=`git_show_parent_commit $testroot/repo` local orig_commit2=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` (cd $testroot/wt && got update -b master > /dev/null) (cd $testroot/wt && got rm beta d/f/g/new > /dev/null) @@ -1487,8 +1487,8 @@ test_rebase_delete_missing_file() { local new_commit1=$(cd $testroot/wt && got info | \ grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ') - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "G gamma/delta" >> $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -1572,7 +1572,7 @@ test_rebase_delete_missing_file() { git -C $testroot/repo checkout -q newbranch local new_commit1=`git_show_head $testroot/repo` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout) echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected @@ -1633,12 +1633,12 @@ test_rebase_rm_add_rm_file() { git -C $testroot/repo checkout -q newbranch - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_orig_commit3=`trim_obj_id 28 $orig_commit3` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` - local short_new_commit3=`trim_obj_id 28 $new_commit3` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_orig_commit3=`trim_obj_id 12 $orig_commit3` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` + local short_new_commit3=`trim_obj_id 12 $new_commit3` echo "D beta" > $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -1730,10 +1730,10 @@ test_rebase_resets_committer() { local new_commit2=`git_show_head $testroot/repo` local new_author_time2=`git_show_author_time $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G gamma/delta" >> $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -1819,10 +1819,10 @@ test_rebase_no_author_info() { local new_commit2=`git_show_head $testroot/repo` local new_author_time2=`git_show_author_time $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $orig_commit1` - local short_orig_commit2=`trim_obj_id 28 $orig_commit2` - local short_new_commit1=`trim_obj_id 28 $new_commit1` - local short_new_commit2=`trim_obj_id 28 $new_commit2` + local short_orig_commit1=`trim_obj_id 12 $orig_commit1` + local short_orig_commit2=`trim_obj_id 12 $orig_commit2` + local short_new_commit1=`trim_obj_id 12 $new_commit1` + local short_new_commit2=`trim_obj_id 12 $new_commit2` echo "G gamma/delta" >> $testroot/stdout.expected echo -n "$short_orig_commit1 -> $short_new_commit1" \ @@ -2096,16 +2096,16 @@ test_rebase_merge_commit() { (cd $testroot/wt && got rebase newbranch2) > $testroot/stdout local new_commit5=`git_show_parent_commit $testroot/repo newbranch2` - local short_orig_commit5=`trim_obj_id 28 $commit5` - local short_new_commit5=`trim_obj_id 28 $new_commit5` + local short_orig_commit5=`trim_obj_id 12 $commit5` + local short_new_commit5=`trim_obj_id 12 $new_commit5` local new_commit4=`git_show_parent_commit $testroot/repo $new_commit5` - local short_orig_commit4=`trim_obj_id 28 $commit4` - local short_new_commit4=`trim_obj_id 28 $new_commit4` + local short_orig_commit4=`trim_obj_id 12 $commit4` + local short_new_commit4=`trim_obj_id 12 $new_commit4` local new_merge_commit=`git_show_branch_head $testroot/repo newbranch2` - local short_orig_merge_commit=`trim_obj_id 28 $merge_commit` - local short_new_merge_commit=`trim_obj_id 28 $new_merge_commit` + local short_orig_merge_commit=`trim_obj_id 12 $merge_commit` + local short_new_merge_commit=`trim_obj_id 12 $new_merge_commit` echo "G beta"> $testroot/stdout.expected echo "$short_orig_commit4 -> $short_new_commit4: edit beta" \ @@ -2193,8 +2193,8 @@ test_rebase_across_merge_commit() { (cd $testroot/wt && got rebase master) > $testroot/stdout local new_commit1=`git_show_head $testroot/repo` - local short_orig_commit1=`trim_obj_id 28 $commit1` - local short_new_commit1=`trim_obj_id 28 $new_commit1` + local short_orig_commit1=`trim_obj_id 12 $commit1` + local short_new_commit1=`trim_obj_id 12 $new_commit1` echo "G gamma/delta"> $testroot/stdout.expected echo "$short_orig_commit1 -> $short_new_commit1: edit delta" \
regress: change how trim_obj_id works