All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Organov <osv@javad.com>
To: git@vger.kernel.org
Subject: Plumbing to rename a ref?
Date: Fri, 23 May 2014 14:11:55 +0400	[thread overview]
Message-ID: <87ha4golck.fsf@osv.gnss.ru> (raw)

Hello,

After convertion of a project from CVS to git, I'd like to rename some
references in the created git repository (before it's published, so no
problems here). Is there a plumbing that would do:

git rename-ref <old_name> <new_name>

for me?

For reference, the (ugly) solution I currrently use is:

# Renamve branches/tags for brevity.
#
# e.g.: version-3-5-branch -> v3.5-branch
#

sed_cmd='sed "s/version-/v/g" | sed "s/\([0-9]\)-\([0-9]\)/\1.\2/g" | sed "s/\([0-9]\)-\([0-9]\)/\1.\2/g"'

if [ -f "packed-refs" ]; then
    rm -rf "packed-refs.new"
    cat "packed-refs" | eval "$sed_cmd" > "packed-refs.new" && mv "packed-refs.new" "packed-refs"
fi

git for-each-ref --format="%(refname)" |
while read -r; do
    ref="$REPLY"
    if [ -f "$ref" ]; then
        new_ref=`echo "$ref" | eval "$sed_cmd"`
        if [ "$ref" != "$new_ref" ]; then
            echo "$ref -> $new_ref"
            mv "$ref" "$new_ref"
        fi
    fi
done

-- Sergey.

             reply	other threads:[~2014-05-23 10:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 10:11 Sergei Organov [this message]
2014-05-23 10:50 ` Plumbing to rename a ref? John Keeping
2014-05-23 11:35   ` Sergei Organov
2014-05-23 12:35     ` Jeff King
2014-05-23 17:11       ` Junio C Hamano
2014-05-23 19:41         ` Jeff King
2014-05-23 17:10   ` Junio C Hamano
2014-05-23 17:14     ` John Keeping

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=87ha4golck.fsf@osv.gnss.ru \
    --to=osv@javad.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.