Skip to content

Commit f37b0c7

Browse files
dschogitster
authored andcommitted
fast-export: respect the possibly-overridden default branch name
When anonymizing commit history, we are careful to leave the branch name of the default branch alone. When the default branch name is overridden via the config or via the environment variable, we will want `git fast-export` to use that overridden name instead. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da15028 commit f37b0c7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

builtin/fast-export.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,17 @@ static const char *anonymize_refname(const char *refname)
515515
};
516516
static struct hashmap refs;
517517
static struct strbuf anon = STRBUF_INIT;
518+
static char *default_branch_name;
518519
int i;
519520

520521
/*
521-
* We also leave "master" as a special case, since it does not reveal
522-
* anything interesting.
522+
* We also leave the default branch name as a special case, since it
523+
* does not reveal anything interesting.
523524
*/
524-
if (!strcmp(refname, "refs/heads/master"))
525+
if (!default_branch_name)
526+
default_branch_name = git_default_branch_name(0);
527+
528+
if (!strcmp(refname, default_branch_name))
525529
return refname;
526530

527531
strbuf_reset(&anon);

0 commit comments

Comments
 (0)