git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Plumbing to rename a ref?
@ 2014-05-23 10:11 Sergei Organov
  2014-05-23 10:50 ` John Keeping
  0 siblings, 1 reply; 8+ messages in thread
From: Sergei Organov @ 2014-05-23 10:11 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-23 19:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23 10:11 Plumbing to rename a ref? Sergei Organov
2014-05-23 10:50 ` 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

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).