Github questions

For the more technical/geeky chat subjects!

Moderator: satrow

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Github questions

Postby Fedor2 » Thu Mar 30, 2017 3:39 am

I want extract commits for one certain date, to apply them in the code, i read github help but not found a clue how to do this.
Is it possible?

adisib
Lunatic
Lunatic
Posts: 316
Joined: Sat Jun 13, 2015 3:34 am
Location: KY

Re: Github questions

Postby adisib » Thu Mar 30, 2017 4:31 am

I don't think it is possible from the Github UI. But you can do it on a local copy of the repository on your computer if you have git installed.

The first thing that would come to mind for me would be something like (use %ad instead of %cd if you want the author date instead of the commit date):

Code: Select all

git log --pretty=format:"%h - %cd" | grep "Mar 16 .* 2017"


Which would return something like:

Code: Select all

ac8e1ef - Thu Mar 16 19:27:33 2017 -0400
f998c78 - Thu Mar 16 19:24:50 2017 -0400
e8ec8a5 - Thu Mar 16 19:15:52 2017 -0400


This gives you the commits for that particular day (March 16 2017 in that example), if you have cloned the repository and run the commands for your local version. You would need grep for this. There's likely to be a much better way, but it isn't coming up off the top of my head.

-----

Edit:
Decided to look on man pages to see if there was an much easier way.

You could do something similar to the above in a much better way with this (note this is author date, not commit date) and you don't need to have grep:

Code: Select all

git log --since="2017-3-15" --until="2017-3-17" --oneline


This will output:

Code: Select all

ac8e1ef [Commit message]
f998c78 [Commit message]
e8ec8a5 [Commit message]

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20067
Joined: Sun Aug 28, 2011 5:27 pm
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Postby Moonchild » Thu Mar 30, 2017 8:45 am

Managing commits in GitHub is very limited. You should probably use a graphical git client like SourceTree for convenience when trying to cherry-pick commits.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Tue Apr 04, 2017 5:42 pm

Still failed to do what i want

First i do

Code: Select all

..\bin\git log --since="2016-12-15" --until="2017-1-10" --patch > p111222

It produces a file, seems valid.
Then

Code: Select all

..\bin\git checkout 27.0_RelBranch

It also executes normally
And finally

Code: Select all

..\bin\git apply p111222

Has bunch of errors
error: patch failed: toolkit/jetpack/moz.build:163
error: toolkit/jetpack/moz.build: patch does not apply
error: patch failed: toolkit/jetpack/moz.build:161
error: toolkit/jetpack/moz.build: patch does not apply
error: dom/media/platforms/ffmpeg/FFmpegFunctionList.h: No such file or director
y
error: dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp: No such file or direc
tory
error: dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h: No such file or directo
ry
error: dom/media/platforms/ffmpeg/FFmpegFunctionList.h: No such file or director
y
error: dom/media/platforms/ffmpeg/FFmpegLibs.h: No such file or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp: No such file or direct


What i do wrong?

adisib
Lunatic
Lunatic
Posts: 316
Joined: Sat Jun 13, 2015 3:34 am
Location: KY

Re: Github questions

Postby adisib » Tue Apr 04, 2017 6:59 pm

Try using format-patch:

Code: Select all

git format-patch C1..C2
git checkout 27.0_RelBranch
git am *.patch

where C1 is the first commit hash that you want to add, and C2 is the last.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 3847
Joined: Tue Oct 09, 2012 7:37 pm

Re: Github questions

Postby New Tobin Paradigm » Tue Apr 04, 2017 6:59 pm

See: viewtopic.php?f=29&t=15014&p=108551#p108551

This explains the basic overview of Pale Moon development.. You should be able to gleam your answer from it. If not.. Someone else can explain.
[ T O B I N W A V E ]

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Tue Apr 11, 2017 6:08 am

adisib
No way, if c1 c2 commit numbers like c93fb24 , format-patch produses a bunch of files but no c93fb24, git am is something to do with mail and errors about *.patch. Tried different format-patch options, stood for nothing the git manual.
Oh dear how it so obscure. why???

So how to do if only one commit c93fb24?

_ntnn
Newbie
Newbie
Posts: 6
Joined: Fri Jan 08, 2016 8:15 pm
Location: noop

Re: Github questions

Postby _ntnn » Tue Apr 11, 2017 11:46 am

Fedor2 wrote:adisib
No way, if c1 c2 commit numbers like c93fb24 , format-patch produses a bunch of files but no c93fb24


Yes, that is what format-patch is designed to do.

git am is something to do with mail and errors about *.patch.

git-am is used to apply patches attached to email, e.g. via git-send-email, to the local code base - not patch files.

To apply diffs (as generated by format-patch) to your local code base you'll have to use git-apply.

What adisib was explaining was that you could go two ways.
a) Generate patch files and apply them to your local tree (git-format-patch then git-apply)
b) Output the sha-sums with git-log and then git-cherry-pick them in your local tree.

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Wed Apr 19, 2017 5:51 pm

At last I can make git do desired patches.
But i stay very confused anyway. Like all commits are applied according to its list, but it seems is not, where to get its right sequence?

Example
https://github.com/MoonchildProductions ... f61ce3cadd
is located before the
https://github.com/MoonchildProductions ... 01400dc154
which is already applied inside 27.0_Relbranch. And it will errors about it.

User avatar
filip
Moongazer
Moongazer
Posts: 14
Joined: Wed Feb 08, 2017 3:52 pm
Location: Serbia

Re: Github questions

Postby filip » Wed Apr 19, 2017 7:34 pm

@Fedor2:

As Moonchild said, "git cherry-pick" is your best friend here.
Since you haven't provided any details it's hard to be specific, so please tell us which commits, from which branch and where to are you trying to apply them ( onto which branch )!?

For the sake of example, I'll assume here that you want to apply some commit range onto master. If so:

1. First make sure that you localy have the branch you're picking from:

Code: Select all

git pull origin branch_name

2. Then make sure you're on the master (target) branch:

Code: Select all

git checkout master

3. Now cherry-pick:

Code: Select all

git cherry-pick C1..C2


:)

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Thu Apr 20, 2017 2:19 am

I'm trying to apply commits after the 27.0_relbranch and before 27.1 on the 27.0_relbranch

I did as [/b]filip[b] suggest, but without pull, i have already all branch, so i decided not do it.

Code: Select all

git checkout 27.0_relbranch
git cherry-pick 27.0_relbranch..8b3e92a

Got

Code: Select all

error: could not apply 79c8db4... Replace dom::TimeRanges with TimeIntervals object
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'


This is even more confusing.


With format-patch method even if i can see which patch failed.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 3847
Joined: Tue Oct 09, 2012 7:37 pm

Re: Github questions

Postby New Tobin Paradigm » Thu Apr 20, 2017 4:39 am

Use a GUI for gods sake and cherry pick only the commit you want.. Also, why do you need to cherry pick at all to an old relbranch.. That isn't how the branch structure is.. structured..
[ T O B I N W A V E ]

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Thu Apr 20, 2017 6:04 am

The matter is not about chery-pick exactly, i was searching any means to make span between 27.0 and 27.1. Because something there breaks one particular site. I think about to apply commits sequentially beginning from 27.0_RelBranch.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20067
Joined: Sun Aug 28, 2011 5:27 pm
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Postby Moonchild » Thu Apr 20, 2017 6:21 am

Why don't you just "checkout" the individual commits on the master branch that you want to look at?
that way you don't have to manually apply/pick anything, and you can bisect to quickly home in on the issue.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Thu Apr 20, 2017 7:21 am

Oh thanks!
This is good idea, but...

Code: Select all

error: The following untracked working tree files would be overwritten by checkout:
        dom/media/platforms/ffmpeg/libav53/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav53/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav53/include/libavformat/version.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/version.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/version.h
Please move or remove them before you can switch branches.
Aborting

Am i wrong, if i delete them? I already have deleted and checkout passed fine, but i worry.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 3847
Joined: Tue Oct 09, 2012 7:37 pm

Re: Github questions

Postby New Tobin Paradigm » Thu Apr 20, 2017 7:29 am

If you are in doubt.. Delete the repository completely and re-clone.
[ T O B I N W A V E ]

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Mon Jun 26, 2017 12:55 pm

Another question.

What is the good way to update source code?
1. Download from the github and replace old code
2. Execute git fetch inside existing old code folder
3. Execute git pull inside existing old code folder
4. Delete older folder and execute git clone

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1050
Joined: Thu Sep 03, 2015 7:47 pm
Location: UA
Contact:

Re: Github questions

Postby JustOff » Mon Jun 26, 2017 1:06 pm

Fetch does not update the code, you need to use pull. But as Tobin has already recommended above you better use GUI. My preferred is SourceTree.
Here are the add-ons I made in a spare time. That was fun!

User avatar
Fedor2
Lunatic
Lunatic
Posts: 324
Joined: Mon Apr 11, 2016 1:26 am

Re: Github questions

Postby Fedor2 » Mon Jun 26, 2017 1:53 pm

So git pull is right, shall do it then. And about gui you suggested - too bad, it wont start in winxp.
I do use git on occasion, gui likely not needed.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20067
Joined: Sun Aug 28, 2011 5:27 pm
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Postby Moonchild » Mon Jun 26, 2017 2:15 pm

I wouldn't recommend using Win XP as a development environment for anything the size of our code base. Besides, how do you think you are going to compile anything?
There are, by the way, several different GUIs for git available, all of them tons better than trying to do it from the command-line.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.


Return to “Technical chat”

Who is online

Users browsing this forum: Linkdex [Bot] and 8 guests