git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git alias quoting help
@ 2016-03-30  4:13 shawn wilson
  2016-03-31 14:27 ` shawn wilson
  2016-04-01 11:05 ` Christian Couder
  0 siblings, 2 replies; 6+ messages in thread
From: shawn wilson @ 2016-03-30  4:13 UTC (permalink / raw)
  To: Git List

I've also tried to make this a plain bash script (w/o the function or
if statements and am failing at the same place). The issue seems to be
with the quoting in the filter-branch | ls-files bit. Also, the end
goal here is to be able to move a directory from one repo and keep the
history. While this works if I do it at the command line, it's just
too many steps (is tedious). Also, if there's a way to do the same
thing with multiple directories in one shot, (or make this work with
something like: cookbooks/{a,b,c} # as a parameter) that'd be perfect.

  reapdir = "!f() { \
    if [ -d "$1" ] ; then \
      git filter-branch --prune-empty --subdirectory-filter "$1" -- --all && \
      git gc --aggressive && \
      git prune && \
      git filter-branch -f --prune-empty --index-filter '\
        git ls-files -s \
          | sed \"s-\\t-&$1-\" \
          | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index
--index-info && \
            mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE'; \
    else \
      echo "No directory $1"; \
    fi; }; \
  f"

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

* Re: git alias quoting help
  2016-03-30  4:13 git alias quoting help shawn wilson
@ 2016-03-31 14:27 ` shawn wilson
  2016-04-01  6:10   ` shawn wilson
  2016-04-01 11:05 ` Christian Couder
  1 sibling, 1 reply; 6+ messages in thread
From: shawn wilson @ 2016-03-31 14:27 UTC (permalink / raw)
  To: Git List

BTW, just trying to get filter-branch to interpret the bash script
string correctly now and it still isn't working:

git filter-branch -f --prune-empty --index-filter "\
  git ls-files -s | \
  sed \"s-\\t\\\"*-&${1}-\" | \
  GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
  git update-index --index-info && \
    mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE \
" HEAD

 I'm guessing bash is grabbing my actual bash shell is grabbing the
GIT_INDEX_FILE declaration for itself. If this is the case, I'm not
sure how to stop it - tried var\=\$var.new and that passes the '\='
which totally messes things up.

Rewrite ef54b77e59c7f4e18f00168ba88a8d2fee795802 (1/76)mv: cannot stat
`/<repo path>/.git-rewrite/t/../index.new': No such file or directory
index filter failed:   git ls-files -s |   sed
"s-\t\"*-&cookbooks/adjoin/-" |   GIT_INDEX_FILE=$GIT_INDEX_FILE.new
git update-index --index-info &&     mv $GIT_INDEX_FILE.new
$GIT_INDEX_FILE

On Wed, Mar 30, 2016 at 12:13 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
> I've also tried to make this a plain bash script (w/o the function or
> if statements and am failing at the same place). The issue seems to be
> with the quoting in the filter-branch | ls-files bit. Also, the end
> goal here is to be able to move a directory from one repo and keep the
> history. While this works if I do it at the command line, it's just
> too many steps (is tedious). Also, if there's a way to do the same
> thing with multiple directories in one shot, (or make this work with
> something like: cookbooks/{a,b,c} # as a parameter) that'd be perfect.
>
>   reapdir = "!f() { \
>     if [ -d "$1" ] ; then \
>       git filter-branch --prune-empty --subdirectory-filter "$1" -- --all && \
>       git gc --aggressive && \
>       git prune && \
>       git filter-branch -f --prune-empty --index-filter '\
>         git ls-files -s \
>           | sed \"s-\\t-&$1-\" \
>           | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index
> --index-info && \
>             mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE'; \
>     else \
>       echo "No directory $1"; \
>     fi; }; \
>   f"

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

* Re: git alias quoting help
  2016-03-31 14:27 ` shawn wilson
@ 2016-04-01  6:10   ` shawn wilson
  2016-04-01 10:30     ` shawn wilson
  0 siblings, 1 reply; 6+ messages in thread
From: shawn wilson @ 2016-04-01  6:10 UTC (permalink / raw)
  To: Git List

FWIW, I (finally) found two projects that like they'll do what I want:
git-splits and git_filter
The later was lacking in documentation and after the build I couldn't
figure it out at a glance and I think git-splits will DWIW.

On Thu, Mar 31, 2016 at 10:27 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
> BTW, just trying to get filter-branch to interpret the bash script
> string correctly now and it still isn't working:
>
> git filter-branch -f --prune-empty --index-filter "\
>   git ls-files -s | \
>   sed \"s-\\t\\\"*-&${1}-\" | \
>   GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
>   git update-index --index-info && \
>     mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE \
> " HEAD
>
>  I'm guessing bash is grabbing my actual bash shell is grabbing the
> GIT_INDEX_FILE declaration for itself. If this is the case, I'm not
> sure how to stop it - tried var\=\$var.new and that passes the '\='
> which totally messes things up.
>
> Rewrite ef54b77e59c7f4e18f00168ba88a8d2fee795802 (1/76)mv: cannot stat
> `/<repo path>/.git-rewrite/t/../index.new': No such file or directory
> index filter failed:   git ls-files -s |   sed
> "s-\t\"*-&cookbooks/adjoin/-" |   GIT_INDEX_FILE=$GIT_INDEX_FILE.new
> git update-index --index-info &&     mv $GIT_INDEX_FILE.new
> $GIT_INDEX_FILE
>
> On Wed, Mar 30, 2016 at 12:13 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> I've also tried to make this a plain bash script (w/o the function or
>> if statements and am failing at the same place). The issue seems to be
>> with the quoting in the filter-branch | ls-files bit. Also, the end
>> goal here is to be able to move a directory from one repo and keep the
>> history. While this works if I do it at the command line, it's just
>> too many steps (is tedious). Also, if there's a way to do the same
>> thing with multiple directories in one shot, (or make this work with
>> something like: cookbooks/{a,b,c} # as a parameter) that'd be perfect.
>>
>>   reapdir = "!f() { \
>>     if [ -d "$1" ] ; then \
>>       git filter-branch --prune-empty --subdirectory-filter "$1" -- --all && \
>>       git gc --aggressive && \
>>       git prune && \
>>       git filter-branch -f --prune-empty --index-filter '\
>>         git ls-files -s \
>>           | sed \"s-\\t-&$1-\" \
>>           | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index
>> --index-info && \
>>             mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE'; \
>>     else \
>>       echo "No directory $1"; \
>>     fi; }; \
>>   f"

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

* Re: git alias quoting help
  2016-04-01  6:10   ` shawn wilson
@ 2016-04-01 10:30     ` shawn wilson
  0 siblings, 0 replies; 6+ messages in thread
From: shawn wilson @ 2016-04-01 10:30 UTC (permalink / raw)
  To: Git List

I think I finally figured out how I want to do this:

git remote add temp ../<temp repo>/
git fetch temp
git merge -s ours --no-commit temp/master
git read-tree --prefix=<wanted directory> -u temp/master:<wanted directory>
git commit -m "foo"

However, when I do this, I've got all of the commits from the original
(temp) repo. How do I prune these out? None of the files show up, but
I do see reference to them in: git log --stat. And nothing I do with
gc or prune seem to have any affect.

On Fri, Apr 1, 2016 at 2:10 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
> FWIW, I (finally) found two projects that like they'll do what I want:
> git-splits and git_filter
> The later was lacking in documentation and after the build I couldn't
> figure it out at a glance and I think git-splits will DWIW.
>
> On Thu, Mar 31, 2016 at 10:27 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> BTW, just trying to get filter-branch to interpret the bash script
>> string correctly now and it still isn't working:
>>
>> git filter-branch -f --prune-empty --index-filter "\
>>   git ls-files -s | \
>>   sed \"s-\\t\\\"*-&${1}-\" | \
>>   GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
>>   git update-index --index-info && \
>>     mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE \
>> " HEAD
>>
>>  I'm guessing bash is grabbing my actual bash shell is grabbing the
>> GIT_INDEX_FILE declaration for itself. If this is the case, I'm not
>> sure how to stop it - tried var\=\$var.new and that passes the '\='
>> which totally messes things up.
>>
>> Rewrite ef54b77e59c7f4e18f00168ba88a8d2fee795802 (1/76)mv: cannot stat
>> `/<repo path>/.git-rewrite/t/../index.new': No such file or directory
>> index filter failed:   git ls-files -s |   sed
>> "s-\t\"*-&cookbooks/adjoin/-" |   GIT_INDEX_FILE=$GIT_INDEX_FILE.new
>> git update-index --index-info &&     mv $GIT_INDEX_FILE.new
>> $GIT_INDEX_FILE
>>
>> On Wed, Mar 30, 2016 at 12:13 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
>>> I've also tried to make this a plain bash script (w/o the function or
>>> if statements and am failing at the same place). The issue seems to be
>>> with the quoting in the filter-branch | ls-files bit. Also, the end
>>> goal here is to be able to move a directory from one repo and keep the
>>> history. While this works if I do it at the command line, it's just
>>> too many steps (is tedious). Also, if there's a way to do the same
>>> thing with multiple directories in one shot, (or make this work with
>>> something like: cookbooks/{a,b,c} # as a parameter) that'd be perfect.
>>>
>>>   reapdir = "!f() { \
>>>     if [ -d "$1" ] ; then \
>>>       git filter-branch --prune-empty --subdirectory-filter "$1" -- --all && \
>>>       git gc --aggressive && \
>>>       git prune && \
>>>       git filter-branch -f --prune-empty --index-filter '\
>>>         git ls-files -s \
>>>           | sed \"s-\\t-&$1-\" \
>>>           | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index
>>> --index-info && \
>>>             mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE'; \
>>>     else \
>>>       echo "No directory $1"; \
>>>     fi; }; \
>>>   f"

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

* Re: git alias quoting help
  2016-03-30  4:13 git alias quoting help shawn wilson
  2016-03-31 14:27 ` shawn wilson
@ 2016-04-01 11:05 ` Christian Couder
  2016-04-01 12:21   ` shawn wilson
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Couder @ 2016-04-01 11:05 UTC (permalink / raw)
  To: shawn wilson; +Cc: Git List

On Wed, Mar 30, 2016 at 6:13 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
> I've also tried to make this a plain bash script (w/o the function or
> if statements and am failing at the same place). The issue seems to be
> with the quoting in the filter-branch | ls-files bit. Also, the end
> goal here is to be able to move a directory from one repo and keep the
> history.

Did you try git subtree
(https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt)?

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

* Re: git alias quoting help
  2016-04-01 11:05 ` Christian Couder
@ 2016-04-01 12:21   ` shawn wilson
  0 siblings, 0 replies; 6+ messages in thread
From: shawn wilson @ 2016-04-01 12:21 UTC (permalink / raw)
  To: Christian Couder; +Cc: Git List

On Fri, Apr 1, 2016 at 7:05 AM, Christian Couder
<christian.couder@gmail.com> wrote:
> On Wed, Mar 30, 2016 at 6:13 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> I've also tried to make this a plain bash script (w/o the function or
>> if statements and am failing at the same place). The issue seems to be
>> with the quoting in the filter-branch | ls-files bit. Also, the end
>> goal here is to be able to move a directory from one repo and keep the
>> history.
>
> Did you try git subtree
> (https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt)?

Yeah, it looked like it left the repo in the same state as
subdirectory-filter and the merge failed. But I'll try it again when I
get to work.

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

end of thread, other threads:[~2016-04-01 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30  4:13 git alias quoting help shawn wilson
2016-03-31 14:27 ` shawn wilson
2016-04-01  6:10   ` shawn wilson
2016-04-01 10:30     ` shawn wilson
2016-04-01 11:05 ` Christian Couder
2016-04-01 12:21   ` shawn wilson

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).