]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'pw/rebase-i-parse-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)
Fixes to code that parses the todo file used in "rebase -i".

* pw/rebase-i-parse-fix:
  rebase -i: fix parsing of "fixup -C<commit>"
  rebase -i: match whole word in is_command()

1  2 
sequencer.c
t/t3404-rebase-interactive.sh
t/t3437-rebase-fixup-options.sh
t/test-lib-functions.sh

diff --cc sequencer.c
index a7e6db4f78f60fc0d62fd8a333c0941085375be4,3c34e70872d0dbd29f639a633d264dbdeb478f33..1c96a75b1e9f8bbe9a7a2e40a3d4dd7bb80a9335
@@@ -2479,42 -2469,13 +2479,41 @@@ static int is_command(enum todo_comman
  {
        const char *str = todo_command_info[command].str;
        const char nick = todo_command_info[command].c;
-       const char *p = *bol + 1;
+       const char *p = *bol;
  
-       return skip_prefix(*bol, str, bol) ||
-               ((nick && **bol == nick) &&
-                (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
-                (*bol = p));
+       return (skip_prefix(p, str, &p) || (nick && *p++ == nick)) &&
+               (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
+               (*bol = p);
  }
  
 +static int check_label_or_ref_arg(enum todo_command command, const char *arg)
 +{
 +      switch (command) {
 +      case TODO_LABEL:
 +              /*
 +               * '#' is not a valid label as the merge command uses it to
 +               * separate merge parents from the commit subject.
 +               */
 +              if (!strcmp(arg, "#") ||
 +                  check_refname_format(arg, REFNAME_ALLOW_ONELEVEL))
 +                      return error(_("'%s' is not a valid label"), arg);
 +              break;
 +
 +      case TODO_UPDATE_REF:
 +              if (check_refname_format(arg, REFNAME_ALLOW_ONELEVEL))
 +                      return error(_("'%s' is not a valid refname"), arg);
 +              if (check_refname_format(arg, 0))
 +                      return error(_("update-ref requires a fully qualified "
 +                                     "refname e.g. refs/heads/%s"), arg);
 +              break;
 +
 +      default:
 +              BUG("unexpected todo_command");
 +      }
 +
 +      return 0;
 +}
 +
  static int parse_insn_line(struct repository *r, struct todo_item *item,
                           const char *buf, const char *bol, char *eol)
  {
Simple merge
Simple merge
Simple merge