preprocessor pass equivalent?
Is there some option, similar to -E gcc option, that would generate the analogous listing for D? What I mean is that I'd like to see all the code in version blocks gone, all the mixin strings expanded. It is probably too much to wish for having the infered auto's expanded...
Re: preprocessor pass equivalent?
On 15.03.2012 12:35, Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? What I mean is that I'd like to see all the code in version blocks gone, all the mixin strings expanded. It is probably too much to wish for having the infered auto's expanded... Not every auto could be expanded, even simple stuff like: auto add(T1,T2)(T1 t1, T2 t2){ return t1+t2; } Expanding mixins could be useful, yet in certain circumstances I'd rather not see the resulting code :) -- Dmitry Olshansky
Re: Vector Swizzling in D
On 14/03/12 18:46, Boscop wrote: On Wednesday, 14 March 2012 at 17:35:06 UTC, Don Clugston wrote: In the last bit of code, why not use CTFE for valid(string s) instead of templates? bool valid(string s) { foreach(c; s) { if (c 'w' || c 'z') return false; } return true; } In fact you can use CTFE for the other template functions as well. In the original version I actually did this, but even with -O -inline -release the opDispatchs call didn't get inlined. I thought it was caused by CTFE-code that prevented the inlining. FWIW, this was the original code using CTFE: --- import std.algorithm: reduce; struct Vec { double[4] v; @property auto X() {return v[0];} @property auto Y() {return v[1];} @property auto Z() {return v[2];} @property auto W() {return v[3];} this(double x, double y, double z, double w) {v = [x,y,z,w];} @property auto opDispatch(string s)() if(s.length = 4 reduce!((s,c)=s 'w' = c c = 'z')(true, s)) { char[] p = s.dup; This won't be CTFEd, because it's not forced to be a compile-time constant. foreach(i; s.length .. 4) p ~= p[$-1]; This too. But, you can do something like: enum p = extend(s); since p is an enum, it must use CTFE. int i(char c) {return [3,0,1,2][c-'w'];} this isn't forced to be CTFE either. return Vec(v[i(p[0])], v[i(p[1])], v[i(p[2])], v[i(p[3])]); } --- (I was using reduce here only to demonstrate D's functional features and nice lambda syntax. Maybe that's what prevented inlining?)
Re: preprocessor pass equivalent?
On 2012-03-15 09:35, Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? What I mean is that I'd like to see all the code in version blocks gone, all the mixin strings expanded. It is probably too much to wish for having the infered auto's expanded... The Eclipse plugin, Descent, has a view that does something like this. Although I don't know how well it works for D2. -- /Jacob Carlborg
Re: preprocessor pass equivalent?
On 2012-03-15 11:04, Jacob Carlborg wrote: On 2012-03-15 09:35, Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? What I mean is that I'd like to see all the code in version blocks gone, all the mixin strings expanded. It is probably too much to wish for having the infered auto's expanded... The Eclipse plugin, Descent, has a view that does something like this. Although I don't know how well it works for D2. It expands mixins, string mixins, replaces scope statements with try/catch/finally and other things. It also has a compile time debugger. -- /Jacob Carlborg
Re: preprocessor pass equivalent?
On Thursday, March 15, 2012 09:35:46 Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? What I mean is that I'd like to see all the code in version blocks gone, all the mixin strings expanded. It is probably too much to wish for having the infered auto's expanded... http://d.puremagic.com/issues/show_bug.cgi?id=5051 - Jonathan M Davis
Re: preprocessor pass equivalent?
On Thursday, 15 March 2012 at 10:09:25 UTC, Jacob Carlborg wrote: The Eclipse plugin, Descent, has a view that does something like this. Although I don't know how well it works for D2. It expands mixins, string mixins, replaces scope statements with try/catch/finally and other things. It also has a compile time debugger. Wow, that's pretty impressive. Does it do aliases also? I read a little more last night and saw that there is an option for json output from dmd, and tried it out. Is that meant to serve the purpose of the gccxml program? I also found mention of a c++ compiler that someone states can compile c++ and output C. Kind of weird, but maybe compiling D to expanded D would not be such a stretch. http://stackoverflow.com/questions/1139793/c-template-preprocessor-tool
Re: preprocessor pass equivalent?
On Thursday, 15 March 2012 at 08:35:48 UTC, Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? You could add one to the compiler in just a few lines; there's already a function that does it, but it isn't called from anywhere. Open up mars.c, and find this comment: Do not attempt to generate output files if errors It is line 1358 in my copy. Right under that if(), add this: for (size_t i = 0; i modules.dim; i++) { m = modules[i]; m-gensymfile(); } compile your new compiler. BACK UP YOUR FILES because this function overwrites the original .d file! $ cat test10.d void main() { auto a = 0; } # we have to backup because otherwise our original source will be lost! $ cp test10.d test10_original.d # you'll have to pass the paths for phobos and druntime unless you bring in a dmd.conf... $ d/dmd2/src/dmd/dmd -Id/dmd2/src/druntime/import -Id/dmd2/src/phobos -L-Ld/dmd2/linux/lib32/test10.d $ cat test10.d // Sym file generated from 'test10.d' import object; void main() { int a = 0; return 0; } It gets ugly if you use a lot of features because this outputs the dmd translations - so foreach becomes for and other lowerings. But you can see basically what the compiler is going to generate for final code.
Re: preprocessor pass equivalent?
On Thu, Mar 15, 2012 at 02:51:33PM +0100, Adam D. Ruppe wrote: On Thursday, 15 March 2012 at 08:35:48 UTC, Jay Norwood wrote: Is there some option, similar to -E gcc option, that would generate the analogous listing for D? You could add one to the compiler in just a few lines; there's already a function that does it, but it isn't called from anywhere. [...] $ cat test10.d void main() { auto a = 0; } # we have to backup because otherwise our original source will be lost! $ cp test10.d test10_original.d # you'll have to pass the paths for phobos and druntime unless you bring in a dmd.conf... $ d/dmd2/src/dmd/dmd -Id/dmd2/src/druntime/import -Id/dmd2/src/phobos -L-Ld/dmd2/linux/lib32/test10.d $ cat test10.d // Sym file generated from 'test10.d' import object; void main() { int a = 0; return 0; } [...] Whoa! This is cool. I might take a stab at making this a compiler option (and writing the output to stdout instead of overwriting the original source). I think this will be VERY useful when learning the language, and also when debugging a compiler bug. T -- EMACS = Extremely Massive And Cumbersome System
Re: preprocessor pass equivalent?
On Thu, 15 Mar 2012 14:34:19 +0100, Jay Norwood j...@prismnet.com wrote: I also found mention of a c++ compiler that someone states can compile c++ and output C. Kind of weird, but maybe compiling D to expanded D would not be such a stretch. That's how early C++ compilers worked. Actually, many compilers work/have worked that way due to the ease of finding a C compiler for just about any given platform.
Re: preprocessor pass equivalent?
On 2012-03-15 14:34, Jay Norwood wrote: On Thursday, 15 March 2012 at 10:09:25 UTC, Jacob Carlborg wrote: The Eclipse plugin, Descent, has a view that does something like this. Although I don't know how well it works for D2. It expands mixins, string mixins, replaces scope statements with try/catch/finally and other things. It also has a compile time debugger. Wow, that's pretty impressive. Does it do aliases also? I think so and showing the actual type for type inference as well. I read a little more last night and saw that there is an option for json output from dmd, and tried it out. Is that meant to serve the purpose of the gccxml program? I also found mention of a c++ compiler that someone states can compile c++ and output C. Kind of weird, but maybe compiling D to expanded D would not be such a stretch. I think LLVM can do this, convert C++ to C, via its byte code. -- /Jacob Carlborg
Re: preprocessor pass equivalent?
There's a pull request to help with debugging string mixins: https://github.com/D-Programming-Language/dmd/pull/426
Re: Vector Swizzling in D
Thanks for the suggestions, I updated the article with an improved CTFE version at the end.
Re: DLL's and D
Yes, this is a lot more clear, thanks. On Thursday, 15 March 2012 at 05:06:16 UTC, Mike Parker wrote: On 3/15/2012 12:26 PM, Chris Pons wrote: I haven't used DLL's much, especially one I've built on my own, so guidance would be appreciated. I'm trying to figure out how to build a DLL which was written in D but i'm not sure i'm doing this right. I'm using VS2010 and Visual D. Visual D has a template for Dll's in D, so I used that to create a new project. The DLL compiles just fine, but i'm having trouble even getting import to work with it. I was following the How-To on this page, http://dlang.org/dll.html#Dcode , but I can't even get import to work. With import, is that supposed to reference the name of the DLL? So if I had one named math.dll, I would write import math.dll? You are misunderstanding what the import statement does. It has absolutely nothing to do with linked libraries or DLLs. It works at the source level. In the example, the source module that is used to compile the DLL is called mydll.d (so is the DLL, but that's irrelevant). Then, in the program that uses it, you use 'import mydll;' to make the declarations in that source module visible to the compiler. For this to work, mydll.d has to be the import path, either relative to test.d in the example, or somewhere you specify with the -I switch. The actual DLL file has no part in this process. It becomes involved later, in the link step. So if your math DLL has source modules named, for example, math/vector.d and math/matrix.d, *those* are what you import in your code. import math.vector; import math.matrix; As long as those modules are somewhere on the import path, that's all you need. The compiler doesn't know or care about the DLL itself at this point. Also, what exactly is different between the dynamic load and static link in the link above? I assume you already understand how to link static libraries to a program -- you pass it to the linker. When using DMD, we typically pass it to the compiler and it hands it off to the linker for us: dmd mymodule.d someLibrary.lib That's the only way to make the symbols in a static library available to the executable at runtime -- those symbols must be compiled into the executable. A DLL is not compiled into the executable. It is loaded at runtime. This can be done in two ways: by the operating system (static load), or manually by the executable (dynamic load). In the example, you compile mydll.d and mydll.def with the following command: dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def This results in mydll.dll and mydll.lib. Now, assuming mydll.lib is in the same directory as test.d, you can use this command to create an executable that will use static loading: dmd test.d mydll.lib The actual symbols of mydll are in mydll.dll. mydll.lib, in this case, does not contain those symbols. Instead, it contains the necessary information for the OS to load the DLL into memory. So when the executable is launched, the OS sees that information, then looks for mydll.dll automatically. For dynamic loading, you don't link with mydll.lib. Instead, you have to implement some extra code in your program to load the DLL and any symbols you need via the Win32 API. The last example on that page does just that. It uses Runtime.loadLibrary (which, under the hood, uses the Win32 function LoadLibrary) to load the DLL. It then loads the getMyClass function using the Win32 function GetProcAddress. Note that it uses the fully mangled name of the function to do so. So, to dynamically load the mydll example, you would add code to test.d to load mydll.dll and to load the pointer for the print function. To compile, you would do this: dmd test.d You no longer need to link with mydll.lib, since you are loading the library manually (dynamically). Would I need to load the DLL for every module that imports it? No. Once the executable is compiled, the concept of modules essentially disappears. Everything is loaded into memory. The DLL is loaded into the executable's address space exactly one time. This makes the symbols available to everything in the same process. Even if you were to manually load the DLL multiple times with Runtime.loadLibrary, the OS would only actually load it once. I believe you've used Derelict, yes? When you call something like DerelictSDL2.load(), Derelict dynamically loads the SDL2 DLL into memory. You only need to call it at one point in your program. After that, it's available to everything in your program. But you still need to import the derelict.sdl2.sdl module into every module uses it so that the compiler knows which declarations are available for you to use. Source modules are used at compile time and must be imported into every module that uses them. DLLs are used at runtime and are only loaded into memory once. I suggest you read up on the difference between
Confused about github rebasing
I'm trying to submit a pull request for druntime, but I'm running into a git problem. This is what I did: - (I forgot that my master branch is out of date) - created a new branch for the fix and committed some changes - switched to master and ran 'git pull' - now master is ahead of the branch by a number of commits - switched back to branch - ran 'git rebase master' to pull in changes from master and apply my changes on top of it - checked that history looks clean - 'git push -u origin newbranch' - submit pull request: but now github thinks my branch has a whole bunch of commits I didn't make (looks like the commits made by rebase). So my question is, what did I do wrong, and what's the right way to pull in the latest changes from upstream without messing up the history? T -- English is useful because it is a mess. Since English is a mess, it maps well onto the problem space, which is also a mess, which we call reality. Similarly, Perl was designed to be a mess, though in the nicests of all possible ways. -- Larry Wall
Re: Confused about github rebasing
On 15-03-2012 20:13, H. S. Teoh wrote: I'm trying to submit a pull request for druntime, but I'm running into a git problem. This is what I did: - (I forgot that my master branch is out of date) - created a new branch for the fix and committed some changes - switched to master and ran 'git pull' - now master is ahead of the branch by a number of commits - switched back to branch - ran 'git rebase master' to pull in changes from master and apply my changes on top of it - checked that history looks clean - 'git push -u origin newbranch' - submit pull request: but now github thinks my branch has a whole bunch of commits I didn't make (looks like the commits made by rebase). So my question is, what did I do wrong, and what's the right way to pull in the latest changes from upstream without messing up the history? T Let's say you're on your branch with your commits. You have a remote called dpl, which is upstream. So: $ git fetch dpl $ git pull --rebase dpl master $ git push origin your branch -f Note the -f, since you're overwriting remote history in your repo. -- - Alex
Re: DLL's and D
Ok, I've actually run into another problem. I've decided to use a static library, since my project is small. I have added the path to the static library's .lib file in my project properties, just like with derelict2. However, I'm not sure how to use import properly. The library in question is in location (relative to my project) Libraries/Math/math.lib. If a module in math.lib is matrix, i've tried import declarations like: import Libraries.Math.math.matrix; //probably very wrong import math.matrix; import matrix; I tried to look at derelict2 for an example, and the VisualD project file there, since it created .lib files. The VS 2010 solution file was in project/visuald/DerelictSDL(etc), and each project refernces modules in Derelict2\DerelictSDL\derelict\sdl\ (for example). So it makes sense that the import would be import derelict.sdl.sdl to import sdl.d. This just lead me to believe that import matrix or import math.matrix should work. Am I wrong in assuming that the library contains the D code I need to use? So I would not be trying to import the .d file I used to construct the static library?
Re: Confused about github rebasing
On Thu, Mar 15, 2012 at 08:59:57PM +0100, Alex Rønne Petersen wrote: On 15-03-2012 20:13, H. S. Teoh wrote: I'm trying to submit a pull request for druntime, but I'm running into a git problem. This is what I did: - (I forgot that my master branch is out of date) - created a new branch for the fix and committed some changes - switched to master and ran 'git pull' - now master is ahead of the branch by a number of commits - switched back to branch - ran 'git rebase master' to pull in changes from master and apply my changes on top of it - checked that history looks clean - 'git push -u origin newbranch' - submit pull request: but now github thinks my branch has a whole bunch of commits I didn't make (looks like the commits made by rebase). So my question is, what did I do wrong, and what's the right way to pull in the latest changes from upstream without messing up the history? T Let's say you're on your branch with your commits. You have a remote called dpl, which is upstream. So: $ git fetch dpl $ git pull --rebase dpl master $ git push origin your branch -f Note the -f, since you're overwriting remote history in your repo. [...] OK thanks! Another question. How to I repair my current history, which is all messed up now? That is, my branch has a whole bunch of commits I didn't make; how do I clean it up? Or is it easier to start from scratch? :) T -- If Java had true garbage collection, most programs would delete themselves upon execution. -- Robert Sewell
Re: Confused about github rebasing
On 15-03-2012 21:49, H. S. Teoh wrote: On Thu, Mar 15, 2012 at 08:59:57PM +0100, Alex Rønne Petersen wrote: On 15-03-2012 20:13, H. S. Teoh wrote: I'm trying to submit a pull request for druntime, but I'm running into a git problem. This is what I did: - (I forgot that my master branch is out of date) - created a new branch for the fix and committed some changes - switched to master and ran 'git pull' - now master is ahead of the branch by a number of commits - switched back to branch - ran 'git rebase master' to pull in changes from master and apply my changes on top of it - checked that history looks clean - 'git push -u origin newbranch' - submit pull request: but now github thinks my branch has a whole bunch of commits I didn't make (looks like the commits made by rebase). So my question is, what did I do wrong, and what's the right way to pull in the latest changes from upstream without messing up the history? T Let's say you're on your branch with your commits. You have a remote called dpl, which is upstream. So: $ git fetch dpl $ git pull --rebase dpl master $ git push originyour branch -f Note the -f, since you're overwriting remote history in your repo. [...] OK thanks! Another question. How to I repair my current history, which is all messed up now? That is, my branch has a whole bunch of commits I didn't make; how do I clean it up? Or is it easier to start from scratch? :) T Well, it really depends on how the history looks... How many commits do you have? If it's a small number, just branch off upstream and cherry-pick each commit. -- - Alex
Re: Confused about github rebasing
On Thu, 15 Mar 2012 13:49:14 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: Another question. How to I repair my current history, which is all messed up now? By not using DVCS which allows you to rewrite history (hint: check Fossil). ;) Otoh, I do not know how much you are 'in love' wiht git, but maybe it would be possible to use hg-git to collaborate with D @github. Sincerely, Gour -- There are principles to regulate attachment and aversion pertaining to the senses and their objects. One should not come under the control of such attachment and aversion, because they are stumbling blocks on the path of self-realization. http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature
Re: Confused about github rebasing
On 15-03-2012 21:53, Gour wrote: On Thu, 15 Mar 2012 13:49:14 -0700 H. S. Teohhst...@quickfur.ath.cx wrote: Another question. How to I repair my current history, which is all messed up now? By not using DVCS which allows you to rewrite history (hint: check Fossil). ;) It's perfectly useful in DVCS. Without it, you'd have a mess of a history when you send your changes upstream. That's not really acceptable. Otoh, I do not know how much you are 'in love' wiht git, but maybe it would be possible to use hg-git to collaborate with D @github. Sincerely, Gour -- - Alex
Re: Confused about github rebasing
On 3/15/2012 3:56 PM, Alex Rønne Petersen wrote: On 15-03-2012 21:53, Gour wrote: On Thu, 15 Mar 2012 13:49:14 -0700 H. S. Teohhst...@quickfur.ath.cx wrote: Another question. How to I repair my current history, which is all messed up now? By not using DVCS which allows you to rewrite history (hint: check Fossil). ;) It's perfectly useful in DVCS. Without it, you'd have a mess of a history when you send your changes upstream. That's not really acceptable. Why would you delete history? Thats pretty much the primary purpose of source control.
Re: Confused about github rebasing
On Thursday, March 15, 2012 16:17:50 Sean Cavanaugh wrote: On 3/15/2012 3:56 PM, Alex Rønne Petersen wrote: On 15-03-2012 21:53, Gour wrote: On Thu, 15 Mar 2012 13:49:14 -0700 H. S. Teohhst...@quickfur.ath.cx wrote: Another question. How to I repair my current history, which is all messed up now? By not using DVCS which allows you to rewrite history (hint: check Fossil). ;) It's perfectly useful in DVCS. Without it, you'd have a mess of a history when you send your changes upstream. That's not really acceptable. Why would you delete history? Thats pretty much the primary purpose of source control. There's a difference between the history in the main repository and the history in a local branch. It may make a lot of sense to make a lot of small commits to your local branch. It's can be easier to manage and rollback small changes that way. But it gets to be pretty ugly if the main history has a whole ton of small commits. So, it's not all that uncommon to rebase at least sections of your local branch's history before merging it into the main repository. You don't lose any of the changes. You just don't have as many commits. And once it's in the main repository, you never rebase. - Jonathan M Davis
Re: Confused about github rebasing
On 15-03-2012 22:17, Sean Cavanaugh wrote: On 3/15/2012 3:56 PM, Alex Rønne Petersen wrote: On 15-03-2012 21:53, Gour wrote: On Thu, 15 Mar 2012 13:49:14 -0700 H. S. Teohhst...@quickfur.ath.cx wrote: Another question. How to I repair my current history, which is all messed up now? By not using DVCS which allows you to rewrite history (hint: check Fossil). ;) It's perfectly useful in DVCS. Without it, you'd have a mess of a history when you send your changes upstream. That's not really acceptable. Why would you delete history? Thats pretty much the primary purpose of source control. I didn't say delete history. Squashing commits together into one just simplifies the history. It makes it easier to review, easier to view in logs, easier to bisect, ... -- - Alex
Re: Confused about github rebasing
On Thu, Mar 15, 2012 at 09:51:30PM +0100, Alex Rønne Petersen wrote: On 15-03-2012 21:49, H. S. Teoh wrote: [...] Another question. How to I repair my current history, which is all messed up now? That is, my branch has a whole bunch of commits I didn't make; how do I clean it up? Or is it easier to start from scratch? :) T Well, it really depends on how the history looks... How many commits do you have? If it's a small number, just branch off upstream and cherry-pick each commit. [...] OK, so I finally figured out how to repair it. Actually, I discovered that my origin/master branch was also broken (probably due to running the wrong git command in it in the past), because it had a bunch of commits from upstream that for some reason had different hashes (maybe the result of attempting to merge from a messed up branch?). This is probably why my topic branch was messed up in the first place, I think. So I did git reset --hard to clean up the history back to the point where it first starting diverging, then pulled from upstream/master (which I confirmed were fast-forward). Then I used `git push -f master` to clean up the history on github. So that takes care of master. Then in my topic branch, which had a messed up history: (branchpoint)---(fast-forwards from upstream) -- master \ \---(merged)---(merged)---...---(my changes) -- topic I did a `git rebase --onto master (my changes)`: (branchpoint)---(fast-forwards from upstream) -- master \ \ \---(now unreachable commits) \--(my changes) -- topic Then I used git push -f to cleanup the history on github. So now everything looks OK again. Phew! I did discover an interesting thing about git though... at one point in the cleanup process I accidentally reset 1 more commit than I had intended, and that commit had no other references to it (unreachable). But luckily I still had its hash available, so `git merge hash` managed to restore it. I guess old unreachable commits are still kept until you run git gc. So that's one of the times when you *don't* want to run git gc. :-) T -- Laissez-faire is a French term commonly interpreted by Conservatives to mean 'lazy fairy,' which is the belief that if governments are lazy enough, the Good Fairy will come down from heaven and do all their work for them.
Re: DLL's and D
On Thu, Mar 15, 2012 at 09:16:45PM +0100, Chris Pons wrote: Ok, I've actually run into another problem. I've decided to use a static library, since my project is small. I have added the path to the static library's .lib file in my project properties, just like with derelict2. However, I'm not sure how to use import properly. The import statement *always* works with D files. Well, technically, you can use a .di file generated by the compiler for your library, but it's basically a reduced form of the library D code. But in either case, you need to import the library D (or Di) file, not the .lib file. The compiler itself doesn't even care about .lib files until it has finished compilation and moved on to the linking stage. The library in question is in location (relative to my project) Libraries/Math/math.lib. If a module in math.lib is matrix, i've tried import declarations like: import Libraries.Math.math.matrix; //probably very wrong It's correct, albeit a bit ugly. To alleviate the ugliness, you can tell the compiler where the root directory for the library is supposed to be. For example, if you invoked dmd with -ILibraries/Math, then you'll be able to say: import math.matrix; and the compiler will know to look for Libraries/Math/math/matrix.d. [...] This just lead me to believe that import matrix or import math.matrix should work. Correct. Provided you specify the right -I option to the compiler. Am I wrong in assuming that the library contains the D code I need to use? So I would not be trying to import the .d file I used to construct the static library? [...] The .lib file contains the *compiled* form of the library, which is no longer D code but machine code. So it can't be used with import. The import statement needs either the original library .d file, or the reduced .di generated by the compiler's -H option. Hope this helps. T -- ASCII stupid question, getty stupid ANSI.
Re: Confused about github rebasing
On 15-03-2012 22:37, H. S. Teoh wrote: On Thu, Mar 15, 2012 at 09:51:30PM +0100, Alex Rønne Petersen wrote: On 15-03-2012 21:49, H. S. Teoh wrote: [...] Another question. How to I repair my current history, which is all messed up now? That is, my branch has a whole bunch of commits I didn't make; how do I clean it up? Or is it easier to start from scratch? :) T Well, it really depends on how the history looks... How many commits do you have? If it's a small number, just branch off upstream and cherry-pick each commit. [...] OK, so I finally figured out how to repair it. Actually, I discovered that my origin/master branch was also broken (probably due to running the wrong git command in it in the past), because it had a bunch of commits from upstream that for some reason had different hashes (maybe the result of attempting to merge from a messed up branch?). This is probably why my topic branch was messed up in the first place, I think. So I did git reset --hard to clean up the history back to the point where it first starting diverging, then pulled from upstream/master (which I confirmed were fast-forward). Then I used `git push -f master` to clean up the history on github. So that takes care of master. Then in my topic branch, which had a messed up history: (branchpoint)---(fast-forwards from upstream)-- master \ \---(merged)---(merged)---...---(my changes)-- topic I did a `git rebase --onto master (my changes)`: (branchpoint)---(fast-forwards from upstream)-- master \ \ \---(now unreachable commits) \--(my changes)-- topic Then I used git push -f to cleanup the history on github. So now everything looks OK again. Phew! I did discover an interesting thing about git though... at one point in the cleanup process I accidentally reset 1 more commit than I had intended, and that commit had no other references to it (unreachable). But luckily I still had its hash available, so `git mergehash` managed to restore it. I guess old unreachable commits are still kept until you run git gc. So that's one of the times when you *don't* want to run git gc. :-) T See also git reflog. It's a life-saver. -- - Alex
Re: Confused about github rebasing
On Thu, Mar 15, 2012 at 11:12:26PM +0100, Alex Rønne Petersen wrote: On 15-03-2012 22:37, H. S. Teoh wrote: [...] I did discover an interesting thing about git though... at one point in the cleanup process I accidentally reset 1 more commit than I had intended, and that commit had no other references to it (unreachable). But luckily I still had its hash available, so `git mergehash` managed to restore it. I guess old unreachable commits are still kept until you run git gc. So that's one of the times when you *don't* want to run git gc. :-) [...] See also git reflog. It's a life-saver. [...] Cool! Didn't know about that. Would've needed it if I didn't still have the hash to the orphaned commit. :) Thanks for the tip. T -- Democracy: The triumph of popularity over principle. -- C.Bond
Re: DLL's and D
On 3/15/12, H. S. Teoh hst...@quickfur.ath.cx wrote: It's correct, albeit a bit ugly. To alleviate the ugliness, you can tell the compiler where the root directory for the library is supposed to be. For example, if you invoked dmd with -ILibraries/Math, then you'll be able to say: import math.matrix; What import path you need to pass depends on the *module declaration* and not the relative location of some module from a directory (this isn't C/C++). If the module declaration is module Math.math.matrix; you'll never be able to do import math.matrix;, you will always have to import it with import Math.math.matrix; regardless of any -I switch. And then when you know the module declaration, figuring out the import switch is easy. It's always one directory UP of the base package.
Re: Shutting down thread with Socket blocking for connection
You could have a look at my attempt: https://github.com/DannyArends/D-coding/tree/master/src/web
Build errors and VS Macros for Build Commands
I've been playing around with VS Macros trying to step away from explicit declarations of library locations. I'm using a google repository as I would like to be able to work on projects either at my desktop or laptop without having to worry about specific library path locations. I tried using a macro like $(SolutionDir) or $(ProjectDir) to specify the current location of the projects but I keep getting this error when building: -- Build started: Project: STDSU, Configuration: Debug Win32 -- Building Debug\STDSU.exe... Error: cannot read file C:\Users\CP\Documents\Visual.d Building Debug\STDSU.exe failed! Details saved as file://C:\Users\CP\Documents\Visual Studio 2010\Projects\D\STDS\Debug\STDSU.buildlog.html == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == However, if I specify a library location explicitly it all compiles just fine. If the location of my VS solution was: C:\Users\CP\Documents\Visual Studio 2010\Projects\D\STDS I would assume $(SolutionDir) would be equivalent. What am I missing?
Re: Confused about github rebasing
H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.719.1331847338.4860.digitalmars-d-le...@puremagic.com... Actually, I discovered that my origin/master branch was also broken (probably due to running the wrong git command in it in the past), because it had a bunch of commits from upstream that for some reason had different hashes (maybe the result of attempting to merge from a messed up branch?). This is probably why my topic branch was messed up in the first place, I think. So I did git reset --hard to clean up the history back to the point where it first starting diverging, then pulled from upstream/master (which I confirmed were fast-forward). Then I used `git push -f master` to clean up the history on github. So that takes care of master. I used to have this problem all the time - now I have a script which checks out master and pulls with -ff-only (in all three repositories) giving me a nice big error if I accidentally committed to master. Although I think I just lost it when my hard drive died yesterday... Get to know rebase -i as well, it can be very useful for untangling history.
Re: Confused about github rebasing
On Fri, Mar 16, 2012 at 01:43:52PM +1100, Daniel Murphy wrote: H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.719.1331847338.4860.digitalmars-d-le...@puremagic.com... Actually, I discovered that my origin/master branch was also broken (probably due to running the wrong git command in it in the past), because it had a bunch of commits from upstream that for some reason had different hashes (maybe the result of attempting to merge from a messed up branch?). This is probably why my topic branch was messed up in the first place, I think. [...] I used to have this problem all the time - now I have a script which checks out master and pulls with -ff-only (in all three repositories) giving me a nice big error if I accidentally committed to master. Although I think I just lost it when my hard drive died yesterday... Ahh, thanks for the tip. I'll probably always use -ff-only from now on. It's always such a mess to clean up if non-ff commits get merged in by a pull. Prevention is better than cure, as they say. Get to know rebase -i as well, it can be very useful for untangling history. [...] Yeah I tried that too, but in my case it was easier to just reset HEAD back to wherever it diverged from and rerun the pull. T -- Don't modify spaghetti code unless you can eat the consequences.
Re: Confused about github rebasing
On 16 March 2012 16:35, H. S. Teoh hst...@quickfur.ath.cx wrote: [...] I used to have this problem all the time - now I have a script which checks out master and pulls with -ff-only (in all three repositories) giving me a nice big error if I accidentally committed to master. Although I think I just lost it when my hard drive died yesterday... Ahh, thanks for the tip. I'll probably always use -ff-only from now on. It's always such a mess to clean up if non-ff commits get merged in by a pull. Prevention is better than cure, as they say. Get to know rebase -i as well, it can be very useful for untangling history. [...] Yeah I tried that too, but in my case it was easier to just reset HEAD back to wherever it diverged from and rerun the pull. Generally I find that pulls should be rebased, ff-only, and local merges done with --no-ff. This means that you have merge history in the tree, which can be useful when trying to do code archaeology, and pulls are forced to be merged properly, rather than using a merge commit, avoiding annoying messages in the log. Git is a strange beast, one moment it is peacful and helpful, the next it is scary and threatening to eat your files. Also, git-svn isn't actually that bad... -- James Miller
Re: Confused about github rebasing
On Fri, Mar 16, 2012 at 04:52:35PM +1300, James Miller wrote: [...] Generally I find that pulls should be rebased, ff-only, and local merges done with --no-ff. This means that you have merge history in the tree, which can be useful when trying to do code archaeology, and pulls are forced to be merged properly, rather than using a merge commit, avoiding annoying messages in the log. Why should merges be --no-ff? Doesn't that create a whole bunch of spurious commits in the history? Git is a strange beast, one moment it is peacful and helpful, the next it is scary and threatening to eat your files. [...] The way you worded it made me misread the last phrase as threatening to eat your face. :-P T -- Skill without imagination is craftsmanship and gives us many useful objects such as wickerwork picnic baskets. Imagination without skill gives us modern art. -- Tom Stoppard
Re: Confused about github rebasing
On 16 March 2012 17:09, H. S. Teoh hst...@quickfur.ath.cx wrote: Generally I find that pulls should be rebased, ff-only, and local merges done with --no-ff. This means that you have merge history in the tree, which can be useful when trying to do code archaeology, and pulls are forced to be merged properly, rather than using a merge commit, avoiding annoying messages in the log. Why should merges be --no-ff? Doesn't that create a whole bunch of spurious commits in the history? Not really, unless you do some really weird stuff. Its mostly due to not re-writing history, fast forwards essentially import your commits into the current branch, making it hard to track where work was done, since commits aren't aware of what branch they are in. I just find it keeps things a little more sensible and friendly for everyone else, since when pushing there is a specific commit + message that people can see, rather than a sudden block of new commits. Git is a strange beast, one moment it is peacful and helpful, the next it is scary and threatening to eat your files. [...] The way you worded it made me misread the last phrase as threatening to eat your face. :-P That too -- James Miller