Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,

if (starts_with(refname, git_replace_ref_base)) {
struct object_id original_oid;
const char *slash = strrchr(refname, '/');
const char *hash = slash ? slash + 1 : refname;
if (!replace_refs_enabled(the_repository))
return 0;
if (get_oid_hex(refname + strlen(git_replace_ref_base),
&original_oid)) {
if (get_oid_hex(hash, &original_oid)) {
warning("invalid replace ref %s", refname);
return 0;
}
Expand Down
17 changes: 17 additions & 0 deletions t/t4207-log-decoration-colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,21 @@ ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
cmp_filtered_decorations
'

test_expect_success 'test replace decoration for nested replace path' '
test_when_finished remove_replace_refs &&

CURRENT_HASH=$(git rev-parse --verify HEAD) &&
git replace --graft HEAD HEAD~2 &&
git update-ref refs/tmp/tmpref refs/replace/$CURRENT_HASH &&
git update-ref -d refs/replace/$CURRENT_HASH &&
git update-ref refs/replace/nested-path/abc/$CURRENT_HASH refs/tmp/tmpref &&

git log --decorate -1 HEAD >actual &&
test_grep "replaced" actual &&

git --no-replace-objects log --decorate -1 HEAD >actual &&
test_grep ! "replaced" actual

'

test_done
10 changes: 10 additions & 0 deletions t/t6050-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,14 @@ test_expect_success '--convert-graft-file' '
test_grep "$EMPTY_BLOB $EMPTY_TREE" .git/info/grafts
'

test_expect_success 'replace ref in a nested path' '
git cat-file commit $HASH2 >actual &&
R=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
git update-ref refs/replace/abc1/$HASH2 $R &&
git show $HASH2 >actual &&
test_grep "O Thor" actual &&
git --no-replace-objects show $HASH2 >actual &&
test_grep "A U Thor" actual
'

test_done
Loading