|
|
@ -133,12 +133,12 @@ static int branch_merged(int kind, const char *name, |
|
|
|
if ((head_rev != reference_rev) && |
|
|
|
if ((head_rev != reference_rev) && |
|
|
|
in_merge_bases(rev, &head_rev, 1) != merged) { |
|
|
|
in_merge_bases(rev, &head_rev, 1) != merged) { |
|
|
|
if (merged) |
|
|
|
if (merged) |
|
|
|
warning("deleting branch '%s' that has been merged to\n" |
|
|
|
warning(_("deleting branch '%s' that has been merged to\n" |
|
|
|
" '%s', but it is not yet merged to HEAD.", |
|
|
|
" '%s', but it is not yet merged to HEAD."), |
|
|
|
name, reference_name); |
|
|
|
name, reference_name); |
|
|
|
else |
|
|
|
else |
|
|
|
warning("not deleting branch '%s' that is not yet merged to\n" |
|
|
|
warning(_("not deleting branch '%s' that is not yet merged to\n" |
|
|
|
" '%s', even though it is merged to HEAD.", |
|
|
|
" '%s', even though it is merged to HEAD."), |
|
|
|
name, reference_name); |
|
|
|
name, reference_name); |
|
|
|
} |
|
|
|
} |
|
|
|
return merged; |
|
|
|
return merged; |
|
|
@ -165,19 +165,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) |
|
|
|
remote = ""; |
|
|
|
remote = ""; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
die("cannot use -a with -d"); |
|
|
|
die(_("cannot use -a with -d")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!force) { |
|
|
|
if (!force) { |
|
|
|
head_rev = lookup_commit_reference(head_sha1); |
|
|
|
head_rev = lookup_commit_reference(head_sha1); |
|
|
|
if (!head_rev) |
|
|
|
if (!head_rev) |
|
|
|
die("Couldn't look up commit object for HEAD"); |
|
|
|
die(_("Couldn't look up commit object for HEAD")); |
|
|
|
} |
|
|
|
} |
|
|
|
for (i = 0; i < argc; i++, strbuf_release(&bname)) { |
|
|
|
for (i = 0; i < argc; i++, strbuf_release(&bname)) { |
|
|
|
strbuf_branchname(&bname, argv[i]); |
|
|
|
strbuf_branchname(&bname, argv[i]); |
|
|
|
if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) { |
|
|
|
if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) { |
|
|
|
error("Cannot delete the branch '%s' " |
|
|
|
error(_("Cannot delete the branch '%s' " |
|
|
|
"which you are currently on.", bname.buf); |
|
|
|
"which you are currently on."), bname.buf); |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
@ -186,7 +186,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) |
|
|
|
|
|
|
|
|
|
|
|
name = xstrdup(mkpath(fmt, bname.buf)); |
|
|
|
name = xstrdup(mkpath(fmt, bname.buf)); |
|
|
|
if (!resolve_ref(name, sha1, 1, NULL)) { |
|
|
|
if (!resolve_ref(name, sha1, 1, NULL)) { |
|
|
|
error("%sbranch '%s' not found.", |
|
|
|
error(_("%sbranch '%s' not found."), |
|
|
|
remote, bname.buf); |
|
|
|
remote, bname.buf); |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -194,21 +194,21 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) |
|
|
|
|
|
|
|
|
|
|
|
rev = lookup_commit_reference(sha1); |
|
|
|
rev = lookup_commit_reference(sha1); |
|
|
|
if (!rev) { |
|
|
|
if (!rev) { |
|
|
|
error("Couldn't look up commit object for '%s'", name); |
|
|
|
error(_("Couldn't look up commit object for '%s'"), name); |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) { |
|
|
|
if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) { |
|
|
|
error("The branch '%s' is not fully merged.\n" |
|
|
|
error(_("The branch '%s' is not fully merged.\n" |
|
|
|
"If you are sure you want to delete it, " |
|
|
|
"If you are sure you want to delete it, " |
|
|
|
"run 'git branch -D %s'.", bname.buf, bname.buf); |
|
|
|
"run 'git branch -D %s'."), bname.buf, bname.buf); |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (delete_ref(name, sha1, 0)) { |
|
|
|
if (delete_ref(name, sha1, 0)) { |
|
|
|
error("Error deleting %sbranch '%s'", remote, |
|
|
|
error(_("Error deleting %sbranch '%s'"), remote, |
|
|
|
bname.buf); |
|
|
|
bname.buf); |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -218,7 +218,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) |
|
|
|
find_unique_abbrev(sha1, DEFAULT_ABBREV)); |
|
|
|
find_unique_abbrev(sha1, DEFAULT_ABBREV)); |
|
|
|
strbuf_addf(&buf, "branch.%s", bname.buf); |
|
|
|
strbuf_addf(&buf, "branch.%s", bname.buf); |
|
|
|
if (git_config_rename_section(buf.buf, NULL) < 0) |
|
|
|
if (git_config_rename_section(buf.buf, NULL) < 0) |
|
|
|
warning("Update of config-file failed"); |
|
|
|
warning(_("Update of config-file failed")); |
|
|
|
strbuf_release(&buf); |
|
|
|
strbuf_release(&buf); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -300,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, |
|
|
|
if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) { |
|
|
|
if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) { |
|
|
|
commit = lookup_commit_reference_gently(sha1, 1); |
|
|
|
commit = lookup_commit_reference_gently(sha1, 1); |
|
|
|
if (!commit) { |
|
|
|
if (!commit) { |
|
|
|
cb->ret = error("branch '%s' does not point at a commit", refname); |
|
|
|
cb->ret = error(_("branch '%s' does not point at a commit"), refname); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -535,7 +535,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru |
|
|
|
free_ref_list(&ref_list); |
|
|
|
free_ref_list(&ref_list); |
|
|
|
|
|
|
|
|
|
|
|
if (cb.ret) |
|
|
|
if (cb.ret) |
|
|
|
error("some refs could not be read"); |
|
|
|
error(_("some refs could not be read")); |
|
|
|
|
|
|
|
|
|
|
|
return cb.ret; |
|
|
|
return cb.ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -548,7 +548,7 @@ static void rename_branch(const char *oldname, const char *newname, int force) |
|
|
|
int recovery = 0; |
|
|
|
int recovery = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (!oldname) |
|
|
|
if (!oldname) |
|
|
|
die("cannot rename the current branch while not on any."); |
|
|
|
die(_("cannot rename the current branch while not on any.")); |
|
|
|
|
|
|
|
|
|
|
|
if (strbuf_check_branch_ref(&oldref, oldname)) { |
|
|
|
if (strbuf_check_branch_ref(&oldref, oldname)) { |
|
|
|
/* |
|
|
|
/* |
|
|
@ -558,35 +558,35 @@ static void rename_branch(const char *oldname, const char *newname, int force) |
|
|
|
if (resolve_ref(oldref.buf, sha1, 1, NULL)) |
|
|
|
if (resolve_ref(oldref.buf, sha1, 1, NULL)) |
|
|
|
recovery = 1; |
|
|
|
recovery = 1; |
|
|
|
else |
|
|
|
else |
|
|
|
die("Invalid branch name: '%s'", oldname); |
|
|
|
die(_("Invalid branch name: '%s'"), oldname); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strbuf_check_branch_ref(&newref, newname)) |
|
|
|
if (strbuf_check_branch_ref(&newref, newname)) |
|
|
|
die("Invalid branch name: '%s'", newname); |
|
|
|
die(_("Invalid branch name: '%s'"), newname); |
|
|
|
|
|
|
|
|
|
|
|
if (resolve_ref(newref.buf, sha1, 1, NULL) && !force) |
|
|
|
if (resolve_ref(newref.buf, sha1, 1, NULL) && !force) |
|
|
|
die("A branch named '%s' already exists.", newref.buf + 11); |
|
|
|
die(_("A branch named '%s' already exists."), newref.buf + 11); |
|
|
|
|
|
|
|
|
|
|
|
strbuf_addf(&logmsg, "Branch: renamed %s to %s", |
|
|
|
strbuf_addf(&logmsg, "Branch: renamed %s to %s", |
|
|
|
oldref.buf, newref.buf); |
|
|
|
oldref.buf, newref.buf); |
|
|
|
|
|
|
|
|
|
|
|
if (rename_ref(oldref.buf, newref.buf, logmsg.buf)) |
|
|
|
if (rename_ref(oldref.buf, newref.buf, logmsg.buf)) |
|
|
|
die("Branch rename failed"); |
|
|
|
die(_("Branch rename failed")); |
|
|
|
strbuf_release(&logmsg); |
|
|
|
strbuf_release(&logmsg); |
|
|
|
|
|
|
|
|
|
|
|
if (recovery) |
|
|
|
if (recovery) |
|
|
|
warning("Renamed a misnamed branch '%s' away", oldref.buf + 11); |
|
|
|
warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11); |
|
|
|
|
|
|
|
|
|
|
|
/* no need to pass logmsg here as HEAD didn't really move */ |
|
|
|
/* no need to pass logmsg here as HEAD didn't really move */ |
|
|
|
if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL)) |
|
|
|
if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL)) |
|
|
|
die("Branch renamed to %s, but HEAD is not updated!", newname); |
|
|
|
die(_("Branch renamed to %s, but HEAD is not updated!"), newname); |
|
|
|
|
|
|
|
|
|
|
|
strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11); |
|
|
|
strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11); |
|
|
|
strbuf_release(&oldref); |
|
|
|
strbuf_release(&oldref); |
|
|
|
strbuf_addf(&newsection, "branch.%s", newref.buf + 11); |
|
|
|
strbuf_addf(&newsection, "branch.%s", newref.buf + 11); |
|
|
|
strbuf_release(&newref); |
|
|
|
strbuf_release(&newref); |
|
|
|
if (git_config_rename_section(oldsection.buf, newsection.buf) < 0) |
|
|
|
if (git_config_rename_section(oldsection.buf, newsection.buf) < 0) |
|
|
|
die("Branch is renamed, but update of config-file failed"); |
|
|
|
die(_("Branch is renamed, but update of config-file failed")); |
|
|
|
strbuf_release(&oldsection); |
|
|
|
strbuf_release(&oldsection); |
|
|
|
strbuf_release(&newsection); |
|
|
|
strbuf_release(&newsection); |
|
|
|
} |
|
|
|
} |
|
|
@ -601,7 +601,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int |
|
|
|
if (!arg) |
|
|
|
if (!arg) |
|
|
|
arg = "HEAD"; |
|
|
|
arg = "HEAD"; |
|
|
|
if (get_sha1(arg, merge_filter_ref)) |
|
|
|
if (get_sha1(arg, merge_filter_ref)) |
|
|
|
die("malformed object name %s", arg); |
|
|
|
die(_("malformed object name %s"), arg); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -675,13 +675,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix) |
|
|
|
|
|
|
|
|
|
|
|
head = resolve_ref("HEAD", head_sha1, 0, NULL); |
|
|
|
head = resolve_ref("HEAD", head_sha1, 0, NULL); |
|
|
|
if (!head) |
|
|
|
if (!head) |
|
|
|
die("Failed to resolve HEAD as a valid ref."); |
|
|
|
die(_("Failed to resolve HEAD as a valid ref.")); |
|
|
|
head = xstrdup(head); |
|
|
|
head = xstrdup(head); |
|
|
|
if (!strcmp(head, "HEAD")) { |
|
|
|
if (!strcmp(head, "HEAD")) { |
|
|
|
detached = 1; |
|
|
|
detached = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (prefixcmp(head, "refs/heads/")) |
|
|
|
if (prefixcmp(head, "refs/heads/")) |
|
|
|
die("HEAD not found below refs/heads!"); |
|
|
|
die(_("HEAD not found below refs/heads!")); |
|
|
|
head += 11; |
|
|
|
head += 11; |
|
|
|
} |
|
|
|
} |
|
|
|
hashcpy(merge_filter_ref, head_sha1); |
|
|
|
hashcpy(merge_filter_ref, head_sha1); |
|
|
@ -701,7 +701,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) |
|
|
|
rename_branch(argv[0], argv[1], rename > 1); |
|
|
|
rename_branch(argv[0], argv[1], rename > 1); |
|
|
|
else if (argc <= 2) { |
|
|
|
else if (argc <= 2) { |
|
|
|
if (kinds != REF_LOCAL_BRANCH) |
|
|
|
if (kinds != REF_LOCAL_BRANCH) |
|
|
|
die("-a and -r options to 'git branch' do not make sense with a branch name"); |
|
|
|
die(_("-a and -r options to 'git branch' do not make sense with a branch name")); |
|
|
|
create_branch(head, argv[0], (argc == 2) ? argv[1] : head, |
|
|
|
create_branch(head, argv[0], (argc == 2) ? argv[1] : head, |
|
|
|
force_create, reflog, track); |
|
|
|
force_create, reflog, track); |
|
|
|
} else |
|
|
|
} else |
|
|
|