X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-tag.c;h=843e9ac056c88bb2c9a8c6ded464096a99f13aff;hb=832e719d79296f1942a2aca5fb067bc610986fc4;hp=c2cca6cb6dc46a221c65092d7c419445d6442b5f;hpb=fa4946b5532ff911565c882892a715616c22cdec;p=git.git diff --git a/builtin-tag.c b/builtin-tag.c index c2cca6cb6..843e9ac05 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -23,59 +23,6 @@ static const char * const git_tag_usage[] = { static char signingkey[1000]; -void launch_editor(const char *path, struct strbuf *buffer, const char *const *env) -{ - const char *editor, *terminal; - - editor = getenv("GIT_EDITOR"); - if (!editor && editor_program) - editor = editor_program; - if (!editor) - editor = getenv("VISUAL"); - if (!editor) - editor = getenv("EDITOR"); - - terminal = getenv("TERM"); - if (!editor && (!terminal || !strcmp(terminal, "dumb"))) { - fprintf(stderr, - "Terminal is dumb but no VISUAL nor EDITOR defined.\n" - "Please supply the message using either -m or -F option.\n"); - exit(1); - } - - if (!editor) - editor = "vi"; - - if (strcmp(editor, ":")) { - size_t len = strlen(editor); - int i = 0; - const char *args[6]; - struct strbuf arg0; - - strbuf_init(&arg0, 0); - if (strcspn(editor, "$ \t'") != len) { - /* there are specials */ - strbuf_addf(&arg0, "%s \"$@\"", editor); - args[i++] = "sh"; - args[i++] = "-c"; - args[i++] = arg0.buf; - } - args[i++] = editor; - args[i++] = path; - args[i] = NULL; - - if (run_command_v_opt_cd_env(args, 0, NULL, env)) - die("There was a problem with the editor %s.", editor); - strbuf_release(&arg0); - } - - if (!buffer) - return; - if (strbuf_read_file(buffer, path, 0) < 0) - die("could not read message file '%s': %s", - path, strerror(errno)); -} - struct tag_filter { const char *pattern; int lines; @@ -178,7 +125,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn) static int delete_tag(const char *name, const char *ref, const unsigned char *sha1) { - if (delete_ref(ref, sha1)) + if (delete_ref(ref, sha1, 0)) return 1; printf("Deleted tag '%s'\n", name); return 0; @@ -336,7 +283,7 @@ static void create_tag(const unsigned char *object, const char *tag, int fd; /* write the template message before editing: */ - path = xstrdup(git_path("TAG_EDITMSG")); + path = git_pathdup("TAG_EDITMSG"); fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (fd < 0) die("could not create file '%s': %s", @@ -348,7 +295,11 @@ static void create_tag(const unsigned char *object, const char *tag, write_or_die(fd, tag_template, strlen(tag_template)); close(fd); - launch_editor(path, buf, NULL); + if (launch_editor(path, buf, NULL)) { + fprintf(stderr, + "Please supply the message using either -m or -F option.\n"); + exit(1); + } unlink(path); free(path); @@ -395,7 +346,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) int annotate = 0, sign = 0, force = 0, lines = 0, list = 0, delete = 0, verify = 0; - char *msgfile = NULL, *keyid = NULL; + const char *msgfile = NULL, *keyid = NULL; struct msg_arg msg = { 0, STRBUF_INIT }; struct option options[] = { OPT_BOOLEAN('l', NULL, &list, "list tag names"), @@ -421,6 +372,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) git_config(git_tag_config, NULL); argc = parse_options(argc, argv, options, git_tag_usage, 0); + msgfile = parse_options_fix_filename(prefix, msgfile); if (keyid) { sign = 1;