Giter VIP home page Giter VIP logo

git-number's Introduction

git-number's People

Contributors

davidvotrubec avatar gruns avatar holygeek avatar jordanlewis avatar kes777 avatar nazri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-number's Issues

git-number -c cd

please introduce this command which will change directory where chosen file are placed;

Unmerged paths:

(use "git add/rm ..." as appropriate to mark resolution)

#1631 both modified: lib/FrontOffice/Controller/Domain/Service.pm

so
git-number-cd 1631
will 'cd' to directory where Service.pm is:
cd lib/FrontOffice/Controller/Domain/

FR: Implement option to generate absolute path

diff --git a/git-number b/git-number
index 221ba8e..d5f7988 100755
--- a/git-number
+++ b/git-number
@@ -141,10 +141,10 @@ while (scalar @ARGV) {
     }
 
     if ( $arg =~ m/^[0-9][0-9]*$/ ) {
-        push @args, split("\n", `git-list $arg`);
+        push @args, map{"$ENV{PWD}/$_"} split("\n", `git-list $arg`);
         $converted=1;
     } elsif ( $arg =~ m/^[0-9][0-9]*-[0-9][0-9]*$/ ) {
-        push @args, split("\n", `git-list $arg`);
+        push @args, map{"$ENV{PWD}/$_"} split("\n", `git-list $arg`);
         $converted=1;
     } else {
         if (index($arg, ' ') != -1) {
kes@work ~/work/projects/github-forks/git-number $ 

With this patch I force git-number to generate absolute path:

$ ge 2 # with patch
subl /home/kes/s/lib/App/Controller/ConnConfig.pm
$ ge 2  # without patch
subl lib/App/Controller/ConnConfig.pm 

This allows me to workaround problem when sublime text editor expand ~s symlink to full absolute path.

Currently I just expand path unconditionally

Reset renamed files do not work

$ alias gr
alias gr='gn -c git reset HEAD'
$ alias gn
alias gn='git-number'
$ gr 1
git reset HEAD "lib/MaitreD/Controllers/Country.pm -> etc/Country.pm"

git-number mix-up numbers

Despite on I wanna to delete 2 file. git-number tries to delete 1 instead.

Details:

 $ pwd -P
/home/kes/work/projects/github-forks/perl5
$ git-number
On branch blead
Your branch is behind 'origin/blead' by 1422 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

1	deleted:    pod/perldelta.pod

Untracked files:
  (use "git add <file>..." to include in what will be committed)

2	pod/perl5242delta.pod

no changes added to commit (use "git add" and/or "git commit -a")
$ git-number -c rm 2
rm /home/kes/work/projects/github-forks/perl5/pod/perldelta.pod
rm: cannot remove '/home/kes/work/projects/github-forks/perl5/pod/perldelta.pod': No such file or directory

'Status after commit and reset --hard' fails due to output formatting

#   Failed test 'Status after commit and reset --hard'
#   at t/001_git-number.t line 115.
#          got: '# On branch master
# nothing to commit, working directory clean
# '
#     expected: '# On branch master
# nothing to commit (working directory clean)
# '

Maybe perhaps due to git 1.7/1.8 differences?

Preserve symlink in path

When file is opened by $EDITOR it is opened as ~/s/filename where s is symlink to some dir.

But when file is opened with git-number it is opened as /home/user/s/filename. The $EDITOR sees them as two different files. That is ugly.

alias gn="git-number"
alias ge="gn -c $EDITOR"
ge 1   # Here 1 is ~/s/filename

Please do not convert file path to absolute path

Add open range definition

For example calling git number add 2- or git number add -3 rather than git number add 1-3.

Many thanks in advance!

Homebrew formulae for git-number?

It would be pretty cool to install this helpful tool via brew install git-number. BAM, done.

Does the formulae exist? Or, would you like for it to exist, if it doesn't?

Number column doesn't take maximum number's width

I've noticed that other columns are aligned in the output, but the first numbers column is always separated from the second one with one space. Is there some easy way to make it always reserve 2 characters at least so that stuff is aligned nicely?

Thanks!

Ignore not file numbers

Here I run git number out of git repository:

git-number -c rsub --port 52697 file
fatal: Not a git repository (or any of the parent directories): .git
rsub --port Please run git-number first file
There are more than one files specified. Opening only run and ignoring other.
/usr/local/bin/rsub: line 305: Please: Servname not supported for ai_socktype
/usr/local/bin/rsub: line 305: /dev/tcp/localhost/Please: Invalid argument
Unable to connect to TextMate on localhost:Please
  1. If command is runned out of repository, you must ignore all numbers suplied
    NOTICE: 'rsub --port Please run git-number first file'

Many tests fail on macOS 10.13

Running make test on macOS 10.13 leads to many failures:

# Using git version 2.13.5 (Apple Git-94)
t/000_setup.t ................ ok

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'fx@bli.(none)')

#   Failed test 'Status after commit and reset --hard'
#   at t/001_git-number.t line 67.
#                   'On branch master
# 
# Initial commit
# 
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
# 
# 1	new file:   one.txt
# 2	new file:   two.txt
# 
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
# 
# 3	deleted:    two.txt
# 
# '
#     doesn't match '(?^:(# )?On branch master
# nothing to commit,? \(?working directory clean\)?
# )'

#   Failed test 'git-number status foo.txt'
#   at t/001_git-number.t line 76.
#                   'On branch master
# 
# Initial commit
# 
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
# 
# 1	new file:   one.txt
# 2	new file:   two.txt
# 
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
# 
# 3	deleted:    two.txt
# 
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
# 
# 4	foo.txt
# 
# '
#     doesn't match '(?^ms:Untracked files:.*\n#?1\tfoo.txt\n.*nothing added to commit but untracked files present \(use "git add" to track\))'

#   Failed test 'git-number status 1'
#   at t/001_git-number.t line 81.
#                   'On branch master
# 
# Initial commit
# 
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
# 
# 	new file:   one.txt
# 
# '
#     doesn't match '(?^ms:Untracked files:.*\n#?\tfoo.txt\n.*nothing added to commit but untracked files present \(use "git add" to track\))'

#   Failed test 'git-number -c ls 1'
#   at t/001_git-number.t line 89.
# +---+----------+----------+
# | Ln|Got       |Expected  |
# +---+----------+----------+
# *  1|'one.txt  |'foo.txt  *
# |  2|'         |'         |
# +---+----------+----------+
cat: two.txt: No such file or directory

#   Failed test ''git-number -c ...' in different dir than 'git-number' was invoked in'
#   at t/001_git-number.t line 97.
# +---+-----+---+-----------+
# | Ln|Got  | Ln|Expected   |
# +---+-----+---+-----------+
# *  1|''   *  1|'Needle\n  *
# |   |     *  2|'          *
# +---+-----+---+-----------+
# Looks like you failed 5 tests of 10.
t/001_git-number.t ........... 
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/10 subtests 
t/002_git-list.t ............. ok
t/003_git-id.t ............... ok

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'fx@bli.(none)')

#   Failed test 'Modified a file in submodule'
#   at t/004_submodule.t line 39.
#                   'On branch master
# 
# Initial commit
# 
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
# 
# 1	new file:   a.txt
# 
# '
#     doesn't match '(?^ms:#?1\tmodified:   b \(modified content\)\n.*no changes added to commit \(use "git add" and/or "git commit -a"\))'

#   Failed test 'Get name of modified submodule using git-list'
#   at t/004_submodule.t line 45.
# +---+---------+----------+
# | Ln|Got      |Expected  |
# +---+---------+----------+
# *  1|'a.txt'  |'b'       *
# +---+---------+----------+
# Looks like you failed 2 tests of 2.
t/004_submodule.t ............ 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests 
t/005_short_status.t ......... ok
t/006_custom_status_color.t .. ok
t/007_git-id-column.t ........ ok

Test Summary Report
-------------------
t/001_git-number.t         (Wstat: 1280 Tests: 10 Failed: 5)
  Failed tests:  5-9
  Non-zero exit status: 5
t/004_submodule.t          (Wstat: 512 Tests: 2 Failed: 2)
  Failed tests:  1-2
  Non-zero exit status: 2
Files=8, Tests=31,  4 wallclock secs ( 0.04 usr  0.02 sys +  1.91 cusr  2.08 csys =  4.05 CPU)
Result: FAIL
make: *** [test] Error 1

It doesn't work properly in VSCode v1.19.0

VSCode v1.19.0. (x64, win10)

It's working good in Mac (High Sierra) VSCode v1.19.0.
But git number doesn't work properly after latest update in Win10(x64) VSCode.

gs, ga, gn, of course git number doesn't work too.

[error message in vscode]

fatal: 'number' appears to be a git command, but we were not
able to execute it. Maybe git-number is broken?

I'm using latest git number.

git number breaks 'git add'

If you add to .gitconfig

[color "status"]
    untracked = red bold

you will not able to add files

$ gn
On branch feature/login_form
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

1   modified:   XXXX

Untracked files:
  (use "git add <file>..." to include in what will be committed)

2   file.txt

no changes added to commit (use "git add" and/or "git commit -a")
$ ga 2
git add "file.txt"
fatal: pathspec 'file.txt' did not match any files
$ 

After git add " starting at file.txt" text is red. It seems git number put ESC sequence into the command

For consistency:

alias gn='git-number'
alias ga='gn add'

Can not call aliases with -c

I have complicated line I've put in shell alias, and can not use it with the -c option. Any time to implement this?

feature-request: display number for `git log --stat`

While I am rebasing

$ git status
interactive rebase in progress; onto 3d276f8
Last command done (1 command done):
   e ece1d11 Do not query DB if user pass wrong arguments
Next commands to do (3 remaining commands):
   pick f6ba33d Setup error if there is no user with supplied login/password
   pick d6950f0 In case of errors we should render 'error' template
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'API_for_frontend' on '3d276f8'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working directory clean

I often required to edit files:

commit ece1d1137f0665243a9b9ab9bcd01c3fd61e8b85
Author: Eugen Konkov <[email protected]>
Date:   Tue Dec 20 19:36:00 2016 +0200

    Do not query DB if user pass wrong arguments

 lib/ArtCoin/Controller/Auth.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

It will be handy to display numbers in this case too

Just a thought

This is a cool library, thank you for sharing. Instead of using the aliases posted, I'm using a function which, if parameters are passed on to git functions (e.g. there are more than 1 parameters passed to gn), then I'm outputting the result of git number -s when the action is complete. It's handy for me, as I always impulsively check git status when working with files, so this does it for me. Maybe worth posting in the readme, maybe not. ¯_(ツ)_/¯

https://github.com/jtsternberg/Dot-Files/blob/master/.git-functions#L40-L44

using git number with the same commands I'm used to

I've been using git-number for a while now, and I just realized that if I alias git to git-number all my favorite git commands like rm work without having to remember another alias.

for bash:
alias git=git-number

Now I don't need a ton of aliases, all the git commands work normally and also with added number syntax!

I haven't found any pitfalls yet, are there any you know of? Is there a reason why this is not suggested in the readme?

Thanks for the great tool!

Quote Issue

If you have a crazy file name with bash variable sequences:

Product-${productVersion} Docker (Build ${buildDate}.${buildNumber}).tar

and it shows in git status like this:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
1	Product-${productVersion} Docker (Build ${buildDate}.${buildNumber}).tar

And you try to remove it with:

git number -c rm 1

The generated command uses double quotes for the filename. Using single quotes would resolve the issue

Generated Command

git number -c rm "Product-\${productVersion} Docker (Build \${buildDate}.\${buildNumber}).tar"

Support for running external commands using numbers

If the command following git number is not a Git command, it would be nice if you tried to run the command as a shell command instead.

So for example, I should be able to type git number emacs 1 to open the first file in emacs.

implement numbers for `git pull`

Fast-forward
 app/lib/SC/Site/Block/Feed.pm                |  9 +++++++++
 app/public/_s/css/common/all.css             |  7 +++++--
 app/public/_s/css/common/common-adaptive.css |  1 +
 app/public/_s/css/common/common-old.css      |  4 +++-
 layouts/common/common.tt                     | 17 +++++++++++++++--
 layouts/common_new/common.tt                 | 17 +++++++++++++++--

git-number should safely escape all arguments

Currently git-number has special handling for arguments with a ' ', '(' or ')' in the name. However there are many other characters that can cause problems, for example '"" or '''.

When outputting the arguments for the command line, the %q type from printf should be used, as this will safely quote all parameters. https://stackoverflow.com/a/6306730/97627

Either that or pass in the arguments to system as parameters rather than as one big string. https://stackoverflow.com/a/3212171/97627

error: unknown option `column=never'

The error is:

$ git-number
error: unknown option `column=never'
usage: git status [options] [--] <filepattern>...

    -v, --verbose         be verbose
    -s, --short           show status concisely
    -b, --branch          show branch information
    --porcelain           machine-readable output
    -z, --null            terminate entries with NUL
    -u, --untracked-files[=<mode>]
                          show untracked files, optional modes: all, normal, no. (Default: all)
    --ignored             show ignored files
    --ignore-submodules[=<when>]
                          ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)

Resolution is commenting out these lines:
https://github.com/holygeek/git-number/blob/master/git-id#L86-L88

# if (! $untracked_in_columns) {
#     $status_opt .= " --column=never";
# }

Here is my git version:

$ git --version
git version 1.7.9

custom color status

git-number doesn't work when the git-status command has a custom header color. for example, something like my ~/.gitconfig :

...

[color "status"]
    header = normal dim
...

Any ideas?!

Implement support for `--short` option of `status` command

$git status --short --branch
## orm
MM ../DbMapper.pm
 M Adapter/Echo.pm
 M DataSet.pm
?? ../../conf/local.conf2
?? ../../dbi.pl
?? Data/
?? ../Mojolicious/Plugin/Control/Button.txt
?? ../../public/dashv2/
?? ../../public/downloads/modals.js
?? ../../public/index.html
?? ../../public/profile/modals.js

$ git-number --short
Unknown option: --short

git-number doesn't seem to work with filenames that include spaces

git-number -s

image

git add "\".config/subl/User/Package Control.sublime-settings\""
fatal: pathspec '".config/subl/User/Package Control.sublime-settings"' did not match any files

image

Does git-number not accommodate adding files through numbers, when filenames include spaces?

Intelligent substitution

I'm not sure how it could be done, but the depth option on clone is taken as a value to substitute when aliasing git to git-number. Would it be crazy to add an exception to the git-number alogrithm to account for this? Are the other cases?

git clone --depth 1 https://github.com/spark/core-common-lib.git
git clone --depth application/themes/default/dashboard.html.twig https://github.com/spark/core-common-lib.git
Cloning into 'core-common-lib'...
fatal: transport: invalid depth option 'application/themes/default/dashboard.html.twig'
Unexpected end of command stream

can not reset renamed files

How to reproduce

$git-number
1   renamed:    abc -> def
2   modified:   ../list

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

3   modified:   ../README.md
4   modified:   ../list

$ git-number -c git reset 1
git reset "abc -> def"
fatal: ambiguous argument 'abc -> def': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

reset deleted files

$ alias gn
alias gn='git-number'
$ gn
On branch design
Your branch is ahead of 'origin/design' by 7 commits.
  (use "git push" to publish your local commits)
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

1	deleted:    ../../../public/assets/bank-logo.png
2	deleted:    ../../../public/assets/close-icon.png
3	deleted:    ../../../public/assets/disable-icon.png
4	deleted:    ../../../public/assets/gilroy-webfont.eot
...

$ gn -c git reset HEAD 1-50
git reset HEAD /home/kes/s/design/dash/dist/. /home/kes/s/design/dash/dist/. /home/kes/s/design/dash/dist/. /home/kes/s/design/dash/dist/. /home/kes/s/design/dash/dist/. 
...

EXPECT:
The file name should be ../../../public/assets/bank-logo.png instead of /home/kes/s/design/dash/dist/.

Any args given after `--' are passed to the underlying command verbatim.

How to reproduce:

$ alias gl
alias gl='f(){ gn log -w -b -p --ignore-blank-lines --full-history $@; unset -f f; }; f'

$ gl 9ce3e165f284d55503eff9b627ef3723854c53bb^ -- lib/Invoice/Schema/Result/Company.pm
git log -w -b -p --ignore-blank-lines --full-history 9ce3e165f284d55503eff9b627ef3723854c53bb^ lib/Invoice/Schema/Result/Company.pm
fatal: ambiguous argument 'lib/Invoice/Schema/Result/Company.pm': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

It seems -- is lost.
I expect command to look like: git log -w -b -p --ignore-blank-lines --full-history 9ce3e165f284d55503eff9b627ef3723854c53bb^ -- lib/Invoice/Schema/Result/Company.pm

Another issue here it seems that it is not possible to pass the number for lib/Invoice/Schema/Result/Company.pm file, eg git log -w -b -p --ignore-blank-lines --full-history 9ce3e165f284d55503eff9b627ef3723854c53bb^ -- 7

I need to pass file after -- because this file was deleted and does not exists at current working directory, so I need to pass its name after --.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.