{"thread":{"id":"2673","subject":"[PATCH] Make git-mv work in subdirectories, too","startedAt":"2005-11-25T11:36:35Z","lastAt":"2005-11-30T14:50:10Z","messageCount":4,"participants":["Johannes Schindelin","Junio C Hamano","Alex Riesen","Josef Weidendorfer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"12728","messageId":"Pine.LNX.4.63.0511251236060.30796@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2673","inReplyTo":null,"subject":"[PATCH] Make git-mv work in subdirectories, too","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-25T11:36:35Z","receivedAt":"2005-11-25T11:36:35Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nTurns out, all git programs git-mv uses are capable of operating in\na subdirectory just fine. So don't complain about it.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tI am no Perl guru, so this might not be the best way to go\n\tabout it. Also, if people agree, I would like to remove the\n\textra check for GIT_DIR validity, since git-rev-parse --git-dir\n\tdoes that already.\n\n git-mv.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\napplies-to: 6b942d45a420cf8f4064f77713d9b218e7fa53cb\nfa750ba9ea3a27b39c8931b18cf0e60a89bf9fd7\ndiff --git a/git-mv.perl b/git-mv.perl\nindex bf54c38..bb61add 100755\n--- a/git-mv.perl\n+++ b/git-mv.perl\n@@ -34,7 +34,8 @@ EOT\n }\n \n # Sanity checks:\n-my $GIT_DIR = $ENV{'GIT_DIR'} || \".git\";\n+my $GIT_DIR = `git-rev-parse --git-dir`;\n+$GIT_DIR =~ s/\\n$//;\n \n unless ( -d $GIT_DIR && -d $GIT_DIR . \"/objects\" && \n \t-d $GIT_DIR . \"/objects/\" && -d $GIT_DIR . \"/refs\") {\n---\n0.99.9.GIT\n"},{"id":"12753","messageId":"7vmzjsdt3z.fsf@assigned-by-dhcp.cox.net","threadId":"2673","inReplyTo":"Pine.LNX.4.63.0511251236060.30796@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Make git-mv work in subdirectories, too","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-26T02:45:52Z","receivedAt":"2005-11-26T02:45:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Turns out, all git programs git-mv uses are capable of operating in\n> a subdirectory just fine. So don't complain about it.\n>\n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n>\n> ---\n>\n> \tI am no Perl guru, so this might not be the best way to go\n> \tabout it. Also, if people agree, I would like to remove the\n> \textra check for GIT_DIR validity, since git-rev-parse --git-dir\n> \tdoes that already.\n\nI think that sounds sane.  You need to grab the exit status from\n`git-rev-parse --git-dir`, so the patch would become something\nlike the attached.  I haven't seriously used git-mv myself, so\nsomebody needs to test it, and if it actually works and Ack on\nit, please.\n\n---\n\ndiff --git a/git-mv.perl b/git-mv.perl\nindex bf54c38..6dda333 100755\n--- a/git-mv.perl\n+++ b/git-mv.perl\n@@ -33,15 +33,9 @@ EOT\n \texit(1);\n }\n \n-# Sanity checks:\n-my $GIT_DIR = $ENV{'GIT_DIR'} || \".git\";\n-\n-unless ( -d $GIT_DIR && -d $GIT_DIR . \"/objects\" && \n-\t-d $GIT_DIR . \"/objects/\" && -d $GIT_DIR . \"/refs\") {\n-    print \"Git repository not found.\";\n-    usage();\n-}\n-\n+my $GIT_DIR = `git rev-parse --git-dir`;\n+exit 1 if $?; # rev-parse would have given \"not a git dir\" message.\n+chomp($GIT_DIR);\n \n our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);\n getopts(\"hnfkv\") || usage;\n"},{"id":"12956","messageId":"20051129221024.GB3033@steel.home","threadId":"2673","inReplyTo":"7vmzjsdt3z.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make git-mv work in subdirectories, too","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2005-11-29T22:10:24Z","receivedAt":"2005-11-29T22:10:24Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Sat, Nov 26, 2005 03:45:52 +0100:\n> > Turns out, all git programs git-mv uses are capable of operating in\n> > a subdirectory just fine. So don't complain about it.\n> >\n> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> >\n> > ---\n> >\n> > \tI am no Perl guru, so this might not be the best way to go\n> > \tabout it. Also, if people agree, I would like to remove the\n> > \textra check for GIT_DIR validity, since git-rev-parse --git-dir\n> > \tdoes that already.\n> \n> I think that sounds sane.  You need to grab the exit status from\n> `git-rev-parse --git-dir`, so the patch would become something\n> like the attached.  I haven't seriously used git-mv myself, so\n> somebody needs to test it, and if it actually works and Ack on\n> it, please.\n\nIt actually works in subdirs.\n\n--- t/t4007-mv.sh\n\n#!/bin/sh\n\ntest_description='git-mv in subdirs'\n. ./test-lib.sh\n\ntest_expect_success \\\n    'prepare reference tree' \\\n    'mkdir path0 path1 &&\n     cp ../../COPYING path0/COPYING &&\n     git-add path0/COPYING &&\n     git-commit -m add -a'\n\ntest_expect_success \\\n    'moving the file' \\\n    'cd path0 && git-mv COPYING ../path1/COPYING'\n\n# in path0 currently\ntest_expect_success \\\n    'commiting the change' \\\n    'cd .. && git-commit -m move -a'\n\ntest_expect_success \\\n    'checking the commit' \\\n    'git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n    grep -E \"^R100.+path0/COPYING.+path1/COPYING\"'\n\ntest_done\n"},{"id":"12991","messageId":"200511301550.10644.Josef.Weidendorfer@gmx.de","threadId":"2673","inReplyTo":"20051129221024.GB3033@steel.home","subject":"Re: [PATCH] Make git-mv work in subdirectories, too","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2005-11-30T14:50:10Z","receivedAt":"2005-11-30T14:50:10Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"On Tuesday 29 November 2005 23:10, Alex Riesen wrote:\n\n> It actually works in subdirs.\n> \n> --- t/t4007-mv.sh\n\n> test_expect_success \\\n>     'moving the file' \\\n>     'cd path0 && git-mv COPYING ../path1/COPYING'\n\nThanks for the test.\nAfter moving to path1, you should check the other way, too:\n\n  cd path0 && git-mv ../path1/COPYING COPYING\n\nAnd this currenly does *not* work because git-mv is only aware\nof the git-controlled files in the subdirectory.\n\nWe probably also should check that source and target are in the\nsame git repo.\n\nJosef\n"}]}