# cg-mv

4 messages from 2005-10-07 to 2005-10-12. Participants: Zack Brown, Petr Baudis, Josef Weidendorfer.
Thread: https://gitlist.dev/t/2040

## Zack Brown, 2005-10-07 14:33

Subject: cg-mv
Message-ID: <20051007143333.GA18843@tumblerings.org>
URL: https://gitlist.dev/e/20051007143333.GA18843%40tumblerings.org

```
Hi,

IIRC, file renaming is something we only care about at read time, we don't
actually need to track it while making the change, because git allows us to
track data from file to file without having to tell it that the data is moving.

So, just to keep certain people happy, why not have the cg-mv command defined to
something like this:

#!/bin/bash
cp $1 $2
cg-rm $1
cg-add $2


Be well,
Zack

-- 
Zack Brown

```

## Petr Baudis, 2005-10-12 10:07

Subject: Re: cg-mv
Message-ID: <20051012100757.GM30889@pasky.or.cz>
URL: https://gitlist.dev/e/20051012100757.GM30889%40pasky.or.cz
In-Reply-To: <20051007143333.GA18843@tumblerings.org>

```
Dear diary, on Fri, Oct 07, 2005 at 04:33:33PM CEST, I got a letter
where Zack Brown <zbrown@tumblerings.org> told me that...
> Hi,

Hello,

> IIRC, file renaming is something we only care about at read time, we don't
> actually need to track it while making the change, because git allows us to
> track data from file to file without having to tell it that the data is moving.
> 
> So, just to keep certain people happy, why not have the cg-mv command defined to
> something like this:
> 
> #!/bin/bash
> cp $1 $2
> cg-rm $1
> cg-add $2

so it should keep the file under the original name as well, but
untraced? That's weird. What about

	#!/usr/bin/env bash

	if [ -e $2 ]; then
		! got_parameter -f && die "dest exists"
		[ -e $1 ] || die "no source nor destination"
	fi
	( [ -e $1 ] && mv $1 $2 ) && cg-add $2 && cg-rm $1

plus quoting and stuff?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

```

## Josef Weidendorfer, 2005-10-12 13:14

Subject: Re: cg-mv
Message-ID: <200510121514.22276.Josef.Weidendorfer@gmx.de>
URL: https://gitlist.dev/e/200510121514.22276.Josef.Weidendorfer%40gmx.de
In-Reply-To: <20051012100757.GM30889@pasky.or.cz>

```
On Wednesday 12 October 2005 12:07, Petr Baudis wrote:
> so it should keep the file under the original name as well, but
> untraced? That's weird. What about
>
> 	#!/usr/bin/env bash
>
> 	if [ -e $2 ]; then
> 		! got_parameter -f && die "dest exists"
> 		[ -e $1 ] || die "no source nor destination"
> 	fi
> 	( [ -e $1 ] && mv $1 $2 ) && cg-add $2 && cg-rm $1
>
> plus quoting and stuff?

Wishlist...
Please make it similar to mv:
* Rename directories, too
* If last argument is an existing directory
  move given files/directories into that directory

Josef

```

## Zack Brown, 2005-10-12 14:28

Subject: Re: cg-mv]
Message-ID: <20051012142809.GA17037@tumblerings.org>
URL: https://gitlist.dev/e/20051012142809.GA17037%40tumblerings.org
In-Reply-To: <20051012100757.GM30889@pasky.or.cz>

```
On Wed, Oct 12, 2005 at 12:07:57PM +0200, Petr Baudis wrote:
> Dear diary, on Fri, Oct 07, 2005 at 04:33:33PM CEST, I got a letter
> where Zack Brown <zbrown@tumblerings.org> told me that...
> > Hi,
> 
> Hello,
> 
> > IIRC, file renaming is something we only care about at read time, we don't
> > actually need to track it while making the change, because git allows us to
> > track data from file to file without having to tell it that the data is moving.
> > 
> > So, just to keep certain people happy, why not have the cg-mv command defined to
> > something like this:
> > 
> > #!/bin/bash
> > cp $1 $2
> > cg-rm $1
> > cg-add $2
> 
> so it should keep the file under the original name as well, but
> untraced? That's weird.

Yes, I mistyped. cp is wrong.

> What about
> 
> 	#!/usr/bin/env bash
> 
> 	if [ -e $2 ]; then
> 		! got_parameter -f && die "dest exists"
> 		[ -e $1 ] || die "no source nor destination"
> 	fi
> 	( [ -e $1 ] && mv $1 $2 ) && cg-add $2 && cg-rm $1
> 
> plus quoting and stuff?

Yes, that's nicer. Maybe the last line should be:

( [ -e $1 ] && mv $1 $2 ) && cg-add $2 && cg-rm $1 || die "unable to rename file"

But you've already done "-e $1" earlier, right? So maybe you don't need it at
the end. Just have:

mv $1 $2 && cg-add $2 && cg-rm $1 || die "unable to rename file"

No?

Be well,
Zack

> 
> -- 
> 				Petr "Pasky" Baudis
> Stuff: http://pasky.or.cz/
> VI has two modes: the one in which it beeps and the one in which
> it doesn't.

-- 
Zack Brown

```
