git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/7] check-ref-format --branch: give Porcelain a way to  grok branch shorthand
Date: Sun, 22 Mar 2009 11:18:29 +0100	[thread overview]
Message-ID: <36ca99e90903220318g2cfb192fi9d4ef0da95e1a65b@mail.gmail.com> (raw)
In-Reply-To: <1237673619-12608-4-git-send-email-gitster@pobox.com>

On Sat, Mar 21, 2009 at 23:13, Junio C Hamano <gitster@pobox.com> wrote:
> The command may not be the best place to add this new feature, but
>
>    $ git check-ref-format --branch "@{-1}"
>
> allows Porcelains to figure out what branch you were on before the last
> branch switching.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin-check-ref-format.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c
> index 701de43..39db6cb 100644
> --- a/builtin-check-ref-format.c
> +++ b/builtin-check-ref-format.c
> @@ -5,9 +5,19 @@
>  #include "cache.h"
>  #include "refs.h"
>  #include "builtin.h"
> +#include "strbuf.h"
>
>  int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
>  {
> +       if (argc == 3 && !strcmp(argv[1], "--branch")) {
> +               struct strbuf sb = STRBUF_INIT;
> +               strbuf_branchname(&sb, argv[2]);
strbuf_branchname() will be introduced in the next patch!

Bert
> +               strbuf_splice(&sb, 0, 0, "refs/heads/", 11);
> +               if (check_ref_format(sb.buf))
> +                       die("'%s' is not a valid branch name", argv[2]);
> +               printf("%s\n", sb.buf + 11);
> +               exit(0);
> +       }
>        if (argc != 2)
>                usage("git check-ref-format refname");
>        return !!check_ref_format(argv[1]);
> --
> 1.6.2.1.299.gda643a
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  parent reply	other threads:[~2009-03-22 10:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-21 22:13 [PATCH 0/7] Clean up interpret_nth_last_branch feature Junio C Hamano
2009-03-21 22:13 ` [PATCH 1/7] check_ref_format(): tighten refname rules Junio C Hamano
2009-03-21 22:13   ` [PATCH 2/7] Rename interpret/substitute nth_last_branch functions Junio C Hamano
2009-03-21 22:13     ` [PATCH 3/7] check-ref-format --branch: give Porcelain a way to grok branch shorthand Junio C Hamano
2009-03-21 22:13       ` [PATCH 4/7] strbuf_branchname(): a wrapper for branch name shorthands Junio C Hamano
2009-03-21 22:13         ` [PATCH 5/7] Fix "branch -m @{-1} newname" Junio C Hamano
2009-03-21 22:13           ` [PATCH 6/7] strbuf_check_branch_ref(): a helper to check a refname for a branch Junio C Hamano
2009-03-21 22:13             ` [PATCH 7/7] checkout -: make "-" to mean "previous branch" everywhere Junio C Hamano
2009-03-22  0:58               ` [PATCH 7/7 (v2)] " Junio C Hamano
2009-03-22 10:18       ` Bert Wesarg [this message]
2009-03-22 21:58         ` [PATCH 3/7] check-ref-format --branch: give Porcelain a way to grok branch shorthand Junio C Hamano
2009-03-21 23:15   ` [PATCH 1/7] check_ref_format(): tighten refname rules Junio C Hamano
2009-03-22 14:41   ` Johannes Schindelin
2009-03-22 23:19     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36ca99e90903220318g2cfb192fi9d4ef0da95e1a65b@mail.gmail.com \
    --to=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).