r-lib / gert

Simple git client for R
https://docs.ropensci.org/gert/
Other
148 stars 32 forks source link

Error in libgit2::git_graph_ahead_behind: object is no commit object #87

Closed pat-s closed 4 years ago

pat-s commented 4 years ago

Trying to switch from {git2r} to {gert}. Do you know why the following errors?

The {git2r} returns are different than the one from {gert} but passing valid tags should be a valid input for git_ahead_behind? Interestingly, not all tags error but only some - however, I do not see a pattern.


    dir <- tempdir()
    usethis::create_from_github("krlmlr/fledge", destdir = dir, open = FALSE)
    #> ✓ Creating '/var/folders/0s/szqcsbtd4011_hjg9z562djc0000gn/T/RtmpX0f5X9/fledge/'
    #> ✓ Cloning repo from 'git@github.com:krlmlr/fledge.git' into '/var/folders/0s/szqcsbtd4011_hjg9z562djc0000gn/T/RtmpX0f5X9/fledge'
    #> ✓ Setting active project to '/private/var/folders/0s/szqcsbtd4011_hjg9z562djc0000gn/T/RtmpX0f5X9/fledge'
    #> ✓ Setting active project to '<no active project>'
    withr::with_dir(paste0(dir, "/fledge"), {
      print(gert::git_tag_list())
      all_tags <- gert::git_tag_list()
      purrr::map(all_tags$name, ~ gert::git_ahead_behind(ref = .x))
    })
    #> # A tibble: 25 x 3
    #>    name        ref                   commit                                  
    #>  * <chr>       <chr>                 <chr>                                   
    #>  1 v0.0.0.9000 refs/tags/v0.0.0.9000 961961d4d6b4d00d0671c07fc1a11e26203eda90
    #>  2 v0.0.0.9001 refs/tags/v0.0.0.9001 7fa7a9cc3f09defb95c61ef0e2fe82dd5d5036ee
    #>  3 v0.0.0.9002 refs/tags/v0.0.0.9002 ff0104dacd0d2c823d2f39d81ee5813a6a58a616
    #>  4 v0.0.0.9003 refs/tags/v0.0.0.9003 8ab5ede70a54f2bbb9767ebc035f61ccb93996f6
    #>  5 v0.0.0.9004 refs/tags/v0.0.0.9004 7cb0dd0d44014d8b2c182748b435d6e17c556555
    #>  6 v0.0.0.9005 refs/tags/v0.0.0.9005 6d01c6253aed589b513da4ec0fe44588cdea77ab
    #>  7 v0.0.0.9006 refs/tags/v0.0.0.9006 88cc363118634d86b9d00838729686e765a16ed9
    #>  8 v0.0.0.9007 refs/tags/v0.0.0.9007 e2adf2d54aacb1dccb9cf708ca018ec87b5d7707
    #>  9 v0.0.0.9008 refs/tags/v0.0.0.9008 cb7be5cd99215622a03de8bc9b2257f4cd340bfc
    #> 10 v0.0.0.9009 refs/tags/v0.0.0.9009 e5a406537d51f6a3c31764f7ce250499cc02e1f8
    #> # … with 15 more rows
    #> Error in libgit2::git_graph_ahead_behind: object is no commit object

<sup>Created on 2020-09-20 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>

<details style="margin-bottom:10px;">
<summary>
Session info
</summary>

    sessioninfo::session_info()
    #> ─ Session info ───────────────────────────────────────────────────────────────
    #>  setting  value                                      
    #>  version  R version 4.0.2 Patched (2020-06-30 r78761)
    #>  os       macOS Big Sur 10.16                        
    #>  system   x86_64, darwin17.0                         
    #>  ui       X11                                        
    #>  language (EN)                                       
    #>  collate  en_US.UTF-8                                
    #>  ctype    en_US.UTF-8                                
    #>  tz       Europe/Zurich                              
    #>  date     2020-09-20                                 
    #> 
    #> ─ Packages ───────────────────────────────────────────────────────────────────
    #>  package     * version     date       lib source                            
    #>  askpass       1.1         2019-01-13 [1] CRAN (R 4.0.0)                    
    #>  assertthat    0.2.1       2019-03-21 [1] CRAN (R 4.0.0)                    
    #>  backports     1.1.10      2020-09-15 [1] CRAN (R 4.0.2)                    
    #>  cli           2.0.2       2020-02-28 [1] CRAN (R 4.0.0)                    
    #>  crayon        1.3.4.9000  2020-09-04 [1] Github (r-lib/crayon@6b3f0c6)     
    #>  credentials   1.3.0       2020-07-21 [1] CRAN (R 4.0.2)                    
    #>  curl          4.3         2019-12-02 [1] CRAN (R 4.0.0)                    
    #>  digest        0.6.25      2020-02-23 [1] CRAN (R 4.0.0)                    
    #>  ellipsis      0.3.1       2020-05-15 [1] CRAN (R 4.0.0)                    
    #>  evaluate      0.14        2019-05-28 [1] CRAN (R 4.0.0)                    
    #>  fansi         0.4.1       2020-01-08 [1] CRAN (R 4.0.0)                    
    #>  fs            1.5.0       2020-07-31 [1] CRAN (R 4.0.2)                    
    #>  gert          0.3.9006    2020-09-04 [1] Github (r-lib/gert@3be3f5b)       
    #>  gh            1.1.0       2020-01-24 [1] CRAN (R 4.0.0)                    
    #>  git2r         0.27.1.9000 2020-06-15 [1] Github (ropensci/git2r@1b1ba56)   
    #>  glue          1.4.2       2020-08-27 [1] CRAN (R 4.0.2)                    
    #>  highr         0.8         2019-03-20 [1] CRAN (R 4.0.0)                    
    #>  htmltools     0.5.0       2020-06-16 [1] CRAN (R 4.0.1)                    
    #>  httr          1.4.2       2020-07-20 [1] CRAN (R 4.0.2)                    
    #>  jsonlite      1.7.1       2020-09-07 [1] CRAN (R 4.0.2)                    
    #>  knitr         1.29        2020-06-23 [1] CRAN (R 4.0.2)                    
    #>  lifecycle     0.2.0       2020-03-06 [1] CRAN (R 4.0.0)                    
    #>  magrittr      1.5         2014-11-22 [1] CRAN (R 4.0.0)                    
    #>  openssl       1.4.3       2020-09-18 [1] CRAN (R 4.0.2)                    
    #>  pillar        1.4.6       2020-07-10 [1] CRAN (R 4.0.2)                    
    #>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 4.0.0)                    
    #>  purrr         0.3.4       2020-04-17 [1] CRAN (R 4.0.0)                    
    #>  R.cache       0.14.0      2019-12-06 [1] CRAN (R 4.0.0)                    
    #>  R.methodsS3   1.8.1       2020-08-26 [1] CRAN (R 4.0.2)                    
    #>  R.oo          1.24.0      2020-08-26 [1] CRAN (R 4.0.2)                    
    #>  R.utils       2.10.1      2020-08-26 [1] CRAN (R 4.0.2)                    
    #>  R6            2.4.1       2019-11-12 [1] CRAN (R 4.0.0)                    
    #>  reprex        0.3.0.9001  2020-08-24 [1] Github (tidyverse/reprex@d3fc4b8) 
    #>  rlang         0.4.7       2020-07-09 [1] CRAN (R 4.0.2)                    
    #>  rmarkdown     2.3.8       2020-09-20 [1] Github (rstudio/rmarkdown@fbd0b1f)
    #>  rprojroot     1.3-2       2018-01-03 [1] CRAN (R 4.0.0)                    
    #>  rstudioapi    0.11        2020-02-07 [1] CRAN (R 4.0.0)                    
    #>  sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 4.0.2)                    
    #>  stringi       1.5.3       2020-09-09 [1] CRAN (R 4.0.2)                    
    #>  stringr       1.4.0       2019-02-10 [1] CRAN (R 4.0.0)                    
    #>  styler        1.3.2.9000  2020-07-05 [1] Github (pat-s/styler@51d5200)     
    #>  sys           3.4         2020-07-23 [1] CRAN (R 4.0.2)                    
    #>  tibble        3.0.3       2020-07-10 [1] CRAN (R 4.0.2)                    
    #>  usethis       1.6.3       2020-09-17 [1] CRAN (R 4.0.2)                    
    #>  utf8          1.1.4       2018-05-24 [1] CRAN (R 4.0.0)                    
    #>  vctrs         0.3.4       2020-08-29 [1] CRAN (R 4.0.2)                    
    #>  withr         2.2.0       2020-04-20 [1] CRAN (R 4.0.0)                    
    #>  xfun          0.17        2020-09-09 [1] CRAN (R 4.0.2)                    
    #>  yaml          2.2.1       2020-02-01 [1] CRAN (R 4.0.0)                    
    #> 
    #> [1] /Users/pjs/Library/R/4.0/library
    #> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

</details>
jeroen commented 4 years ago

Thanks for the report. This looks like a bug that has to do with the difference between light-weight tags and annotated tags. It does not seem to happen for light-weight tags, only for annotated tags...

Possibly related to https://github.com/r-lib/gert/issues/43

jeroen commented 4 years ago

Minimal example:

tmp <- tempfile()
gert::git_clone('https://github.com/krlmlr/fledge', tmp)

gert::git_ahead_behind(ref='v0.0.0.9000', repo = tmp)
gert::git_log(ref='v0.0.0.9000', repo = tmp)
pat-s commented 4 years ago

I am facing the same error again in another instance:

    library(gert)
    #> Linking to libgit2 v1.0.1, ssh support: YES
    #> Global config: /Users/pjs/.gitconfig
    #> Default user: pat-s <patrick.schratz@gmail.com>
    tmp <- tempfile()
    gert::git_clone("https://github.com/krlmlr/fledge", tmp)
    last_commit <- git_log(repo = tmp)$commit[1]
    tag <- git_tag_list("v0.0.3.9007", repo = tmp)$commit
    git_ahead_behind(last_commit, tag, repo = tmp)
    #> Error in libgit2::git_graph_ahead_behind: object is no commit object

Created on 2020-10-04 by the reprex package (v0.3.0.9001)

Session info sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.2 Patched (2020-09-21 r79235) #> os macOS Big Sur 10.16 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2020-10-04 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> askpass 1.1 2019-01-13 [1] CRAN (R 4.0.0) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0) #> backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2) #> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0) #> crayon 1.3.4.9000 2020-09-04 [1] Github (r-lib/crayon@6b3f0c6) #> credentials 1.3.0 2020-07-21 [1] CRAN (R 4.0.2) #> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2) #> gert * 0.3.9007 2020-10-04 [1] Github (r-lib/gert@e2edef1) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.1) #> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0) #> openssl 1.4.3 2020-09-18 [1] CRAN (R 4.0.2) #> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0) #> R.cache 0.14.0 2019-12-06 [1] CRAN (R 4.0.0) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.0.2) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.0.2) #> R.utils 2.10.1 2020-08-26 [1] CRAN (R 4.0.2) #> reprex 0.3.0.9001 2020-08-24 [1] Github (tidyverse/reprex@d3fc4b8) #> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2) #> rmarkdown 2.4.1 2020-10-02 [1] Github (rstudio/rmarkdown@29aad5e) #> rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2) #> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0) #> styler 1.3.2.9000 2020-07-05 [1] Github (pat-s/styler@51d5200) #> sys 3.4 2020-07-23 [1] CRAN (R 4.0.2) #> tibble 3.0.3 2020-07-10 [1] CRAN (R 4.0.2) #> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2) #> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2) #> xfun 0.18 2020-09-29 [1] CRAN (R 4.0.2) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0) #> #> [1] /Users/pjs/Library/R/4.0/library #> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
jeroen commented 4 years ago

Thanks for catching this. I think it's fixed for real now.